Repository navigation
Enhance security-audit skill: CG alerts integration and viewer improvements - #4058
Conversation
The security audit skill previously only checked NVD/web sources for CVEs in native dependencies. It completely missed the ~112 CG alerts flagged by the SkiaSharp-Native Azure DevOps pipeline (definition 26493), which scans Docker container images for OS package, npm, Rust crate, and NuGet vulnerabilities. Added Step 9 with: - How to query CG alerts via az CLI (timeline → log IDs → parse CVEs) - Alert categorization (Alpine sysroot, Debian base, build toolchain, NuGet) - Key Dockerfile paths that control the vulnerable packages - JSON report schema extension for cgAlerts section - CG portal links for manual review Co-authored-by: Copilot <[email protected]>
Created query-cg-alerts.py that automatically: - Discovers the latest SkiaSharp-Native build (pipeline 26493) - Identifies representative CG logs per container type (alpine, debian11, debian13, bionic, wasm) from the build timeline - Parses and deduplicates all CVEs across jobs - Categorizes by source (Alpine sysroot, Debian base, npm, Rust, NuGet) - Outputs human-readable summary or structured JSON (--json flag) Updated skill doc to note that there is NO build-independent CG REST API - governance.visualstudio.com doesn't expose alert data through any documented endpoint. The script achieves equivalent results by sampling the latest build's CG logs, which report all active registration-level alerts. Co-authored-by: Copilot <[email protected]>
Move CG alert checking from Step 9 to Step 6 in the instruction sections to match the workflow overview. Renumber subsequent steps (old 6→7, 7→8, 8→9). Use #### sub-headings within Step 6 instead of ### to keep the hierarchy correct. Co-authored-by: Copilot <[email protected]>
The script now automatically discovers and queries the latest builds from main AND all active release/* branches. Results are deduplicated and annotated with branch coverage, showing which CVEs are exclusive to specific branches. Also switched from az CLI subprocess calls to direct REST API requests using urllib for faster execution and better error handling. Key improvements: - --branch flag to query a specific branch - Branch coverage summary showing per-branch alert counts - Branch-exclusive alert highlighting - GHSA advisory ID support in addition to CVEs - Debian 13 rsync alerts now properly categorized Co-authored-by: Copilot <[email protected]>
- Query both SkiaSharp-Native (26493) and SkiaSharp (10789) pipelines since together they make up the shipped build - Add --pipeline flag (native/managed/both, default: both) - Add 'COMPONENT STACKS' output section showing components with most CVEs (e.g., binutils 2.39-r2 has 15 CVEs, busybox has 35) - Track which pipeline each alert comes from - Fix branch deduplication in coverage report - Update SKILL.md to document both pipelines Co-authored-by: Copilot <[email protected]>
Security auditing must not sample or skip any jobs. The script now queries every successful Component Governance log in each build (60+ jobs in the native pipeline alone) and deduplicates the results. Co-authored-by: Copilot <[email protected]>
Categorization now derives from job names (where the alert was found) rather than a brittle list of hardcoded component names. This handles new packages, versions, or distros appearing without code changes: - Distro:N: prefix + alpine job → Alpine sysroot - Distro:N: prefix + non-alpine job → Debian N base image - Microsoft.*/System.*/NuGet.* → NuGet dependency - Found only in Prepare/Merge jobs → SDK/toolchain dependency - Everything else → Build toolchain dependency Co-authored-by: Copilot <[email protected]>
The script is consumed by AI (security-audit skill), so: - Default output is now JSON with every alert fully enumerated - Each alert includes: id, component, severity, category, all source jobs, branches, and pipelines — nothing truncated or summarized - --text flag for human-readable output (also lists every CVE) - Removed --json flag (JSON is now the default) Co-authored-by: Copilot <[email protected]>
The script takes 2-3 minutes to query all build logs. Skill instructions now tell AI to run it once, cache the JSON, and reference the cached result for the remainder of the audit — never re-running mid-session. Co-authored-by: Copilot <[email protected]>
Progress messages are now opt-in with --verbose/-v since the script is consumed by AI which only needs the JSON on stdout. Co-authored-by: Copilot <[email protected]>
- Add Component Governance section with severity cards, category table,
high alerts detail, and pipeline links
- Fix PR links rendering #[object Object] by handling {number, repo, title}
objects alongside plain number format
- Fix issue links similarly for {number, state} objects
- Add warning banner: build-chain vulnerabilities can compromise artifacts
Co-authored-by: Copilot <[email protected]>
- Replace 'highAlerts only' with full allAlerts table (all 121 alerts) - Show every severity: High, Medium, Low — no filtering - Remove dismissive 'note' about not shipping - Remove 'Fix' column from categories (editorial suggestion) - Add columns: Severity, Pipelines, Branches per alert - No decisions made about what to show — everything listed Co-authored-by: Copilot <[email protected]>
- Remove categorize_alert() function from query script - Remove byCategory from JSON output - Remove category column from HTML viewer table - Remove categories section from HTML viewer - Text mode now groups directly by component Co-authored-by: Copilot <[email protected]>
- Parse '--- Found at: ---' sections from CG logs to extract actual file paths where each component was discovered - Add 'paths' field to each alert in JSON output - Show 'Found At' column in HTML viewer with code-formatted paths - Add 'Open in AzDO' link to CG registration page in header - Show paths in text mode output per component Co-authored-by: Copilot <[email protected]>
- Each component gets its own collapsible card showing: - Highest severity badge + component name + CVE count + branches - Found-at paths (code formatted) - CVE table with NVD links - Pipeline list - Sorted: highest severity first, then by CVE count - All collapsed by default for scannability Co-authored-by: Copilot <[email protected]>
- Add security-audit-schema.json (Draft 2020-12) covering all report fields - Add validate-security-audit.py with schema + semantic checks: - Summary counts match finding statuses - totalCves matches actual CVE arrays - CG alerts have enumerable data (allAlerts or uniqueCVEs) - bySeverity counts match alert severities - Findings have unique dependencies - nextSteps sorted by priority - Viewer now handles both allAlerts and uniqueCVEs/categories formats - SKILL.md: added validation as Step 8 (mandatory before render) Co-authored-by: Copilot <[email protected]>
- Add queriedAt ISO timestamp to JSON output for freshness verification - Rewrite SKILL.md caching instructions to use file (not shell variable) The old CG_DATA=$(...) pattern was lost between tool calls since sync shells are ephemeral. Saving to /tmp/cg-alerts-cache.json persists across calls and makes the caching foolproof. - Upgraded warning from⚠️ to 🛑 CRITICAL to emphasize importance Co-authored-by: Copilot <[email protected]>
The agent was running query-cg-alerts.py 3 times (observed in session eceb5fb5) because the caching instruction was buried in a subsection. Now the FIRST thing in Step 6 is the cache command with a stop-sign emoji and explicit 'do NOT run again' language. Co-authored-by: Copilot <[email protected]>
Root cause: the skill agent summarized CG data into categories instead of including the full alerts array. The viewer groups by component itself — it needs individual alerts with id/component/severity/paths. Changes: - SKILL.md: explicit DO NOT list for categories/uniqueCVEs formats - Validator: errors if 'alerts' array is missing (categories alone fails) - Viewer: accepts 'alerts' key (script output) in addition to 'allAlerts' - Viewer: improved categories fallback for older reports (topComponents) - Schema: added 'alerts' as primary key alongside legacy 'allAlerts' Co-authored-by: Copilot <[email protected]>
Each audit run produces a fresh JSON/HTML pair. No need for backwards compatibility with old formats. Simplified to one format: - cgAlerts.alerts[] is REQUIRED (not allAlerts, uniqueCVEs, or categories) - Schema: additionalProperties: false on cgAlerts (strict) - Viewer: reads cg.alerts directly, no fallback normalization - Validator: errors if alerts array is missing Co-authored-by: Copilot <[email protected]>
- Add CG Alerts card to top summary row (5 cards now) - HIGH CG alerts count toward 'Needs Attention' total - CG components appear in Dependency Overview table sorted by severity - Clicking a CG row scrolls to the CG detail section - Remove 'Ships in NuGet?' column from SKILL.md category table - Add explicit instruction: do NOT editorialize about shipping - Viewer uses col-md (auto-width) for 5 cards instead of col-md-3 Co-authored-by: Copilot <[email protected]>
'minimatch 3.1.2' -> name: 'minimatch', version: '3.1.2' 'Debian:12:binutils 2.39-r2' -> name: 'Debian:12:binutils', version: '2.39-r2' The py script stores name+version as one string (from CG log format). The viewer now splits on the last space before a digit-leading token to populate both the Dependency and Current Version columns. Co-authored-by: Copilot <[email protected]>
…t check - Sort 'Dependencies with CVEs' alphabetically (not by severity — was jamming CG HIGH items at top above everything else) - CG entries don't count toward 'missing from cgmanifest' warning - Add '🛡️ N CG components' to status text Co-authored-by: Copilot <[email protected]>
- Sort by severity first (High at top), then alphabetical - CG status mapping: High/Critical -> needs_attention, Medium -> undiscovered (new/unresolved), Low -> clean - Removes incorrect 'in_progress' for Medium/Low CG items Co-authored-by: Copilot <[email protected]>
Low severity = undiscovered (not clean). A CVE is a CVE regardless of severity level. Only items with zero CVEs should be 'clean'. Co-authored-by: Copilot <[email protected]>
The 'Security' column (now renamed 'Status') shows the audit action status. The new 'Severity' column shows the highest CVE severity (Critical/High/Medium/Low) for each dependency, color-coded with the same classes used elsewhere. Regular deps derive severity from their CVE list; CG items use their alert severity directly. Co-authored-by: Copilot <[email protected]>
CVEs from different sources use inconsistent casing (HIGH vs High). Normalize to title-case for display and for sevOrder lookups. Co-authored-by: Copilot <[email protected]>
📦 Try the packages from this PRWarning Do not run these scripts without first reviewing the code in this PR. Step 1 — Download the packages bash / macOS / Linux: curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 4058PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4058"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-4058/packages --name skiasharp-pr-4058More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-4058 |
Viewer fixes: - C5: 'verified from SkMilestone.h' now conditional on upstreamVerified - C6: Add Critical severity card, include Critical+High in Needs Attention count - C7: CG Medium/Low mapped to 'cg_tracked' (not 'undiscovered' — wrong semantics) - S2: Guard optional commit fields (no more undefined links) - S3: Unknown severity renders as italic red (not silently Low) - S5: Header shows 'X CVEs · Y CG alerts' (not just 'X CVEs analyzed') - S6: GHSA IDs link to github.com/advisories (not broken NVD links) SKILL.md fixes: - C1: Replace /tmp/ paths with output/ai/ (agent runtime may forbid /tmp) - C2: Fix duplicate Step 9 → Step 10 for markdown summary - C3: 'sampling' → 'enumerating every CG log' (matches script behavior) - C4: Remove 'Categorize by source' contradiction, add clarifying note - Q3: Remove 2>/dev/null that hides auth errors - Q8: 'tens of build logs' instead of hard-coded '60+' Schema fixes: - S4: Lock summary with additionalProperties: false - S7: Enum-validate CG alert severity (Critical/High/Medium/Low) Validator fix: - Q9: Warn when cgAlerts block is missing entirely Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR enhances the .agents/skills/security-audit workflow by integrating Azure DevOps Component Governance (CG) alert collection into the security-audit skill, and upgrading the generated HTML viewer + JSON validation to treat CG findings as first-class security signals alongside dependency CVEs.
Changes:
- Add a CG alert query script that enumerates CG logs across SkiaSharp-Native and SkiaSharp pipelines and outputs a structured
cgAlertspayload. - Upgrade the HTML viewer to surface CG alerts in the summary, dependency overview table, and a dedicated collapsible CG details section (including GHSA link handling).
- Introduce a Draft 2020-12 JSON Schema and a validator script that performs schema + semantic consistency checks before rendering.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| .agents/skills/security-audit/SKILL.md | Updates the skill workflow and instructions to require CG alert querying + caching and adds a mandatory validation step. |
| .agents/skills/security-audit/scripts/viewer.html | Enhances the HTML viewer with CG alert rendering, summary/overview integration, severity display, and robust PR/issue/advisory linking. |
| .agents/skills/security-audit/scripts/validate-security-audit.py | Adds a report validation CLI that checks schema compliance and key semantic invariants. |
| .agents/skills/security-audit/scripts/query-cg-alerts.py | Adds an AzDO API-backed CG log enumerator/parser producing structured cgAlerts output for audits. |
| .agents/skills/security-audit/references/security-audit-schema.json | Adds a strict machine-readable schema defining the security audit JSON format, including required cgAlerts.alerts[]. |
Comments suppressed due to low confidence (1)
.agents/skills/security-audit/references/security-audit-schema.json:249
- Similarly, the viewer supports
prsentries as either plain numbers or objects, but the schema restrictsprs[]items totype: objectonly. This can cause schema validation failures for otherwise-renderable reports. Consider widening the schema to match the accepted formats (or standardize the report format and update viewer/skill accordingly).
"prs": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
|
📖 Documentation Preview The documentation for this PR has been deployed and is available at: 🔗 View Staging Site This preview will be updated automatically when you push new commits to this PR. This comment is automatically updated by the documentation staging workflow. |
… validator errors - Make git remote add idempotent (fallback to set-url) - CG badge includes Critical+High in danger condition - Schema enforces objects with required 'number' for issues/prs - Validator promotes summary count mismatches to errors (exit 1) Co-authored-by: Copilot <[email protected]>
Summary
Adds Component Governance (CG) alert querying to the security-audit skill and significantly improves the HTML viewer for presenting security findings.
Key Changes
CG Alert Integration
query-cg-alerts.pyqueries AzDO build logs for CG alerts from both SkiaSharp-Native and SkiaSharp pipelinesViewer Improvements
Skill Workflow
alerts[]array (no categories/summaries)queriedAtISO timestamp for freshness trackingSchema
cgAlerts.alerts[]required,additionalProperties: false