Skip to content

feat(python-sbom)!: cut over runtime CVE gate from Trivy to Grype (#152) - #229

Merged
williaby merged 2 commits into
mainfrom
claude/sbom-trivy-cutover-152
Jun 28, 2026
Merged

williaby merged 2 commits into
mainfrom
claude/sbom-trivy-cutover-152

Conversation

@williaby

Copy link
Copy Markdown
Collaborator

Summary

Completes the issue #152 Trivy-to-Grype cutover. Promotes the Grype scan job in python-sbom.yml to gating and removes Trivy and its parallel-run scaffolding. The blocking precondition (detection parity) was validated on the post-repair window and recorded in #152: zero divergence in either direction across 7 repos with comparable data, and identical CVSS scores on every shared finding (including a gate-relevant cryptography HIGH).

Motivation: Trivy's release infrastructure was compromised in March 2026 with vulnerability-DB updates suspended, making the SBOM scanner itself a supply-chain risk. Grype (Anchore) is unaffected.

What changed

  • Removed the scan-runtime (Trivy) job.
  • Promoted scan-runtime-grype to gating: fail-build now mirrors fail-on-vulnerabilities, the job-level continue-on-error is gone, and it gains the same generate-sbom state guard the Trivy job had.
  • Preserved the check name. The promoted job keeps name: Scan Runtime Dependencies (what the Trivy job used), so consumer rulesets requiring that status-check context keep passing without per-repo changes.
  • Removed the trivyignore-path input. Verified no consumer passes it (checked every org SBOM caller), so no workflow_call input-validation startup_failure can occur. Grype CVE suppression uses the existing grype-config-path (.grype.yaml).
  • Removed the parity-summary job and scripts/compare_scanner_parity.py (+ its test): parallel-run-only scaffolding.
  • OSV-Scanner remains a second keyless gate.
  • CHANGELOG updated (### Changed + ### Breaking Changes).

What did NOT change

Validation

  • actionlint clean (no new warnings; shellcheck-info and job.workflow_* counts both went down vs origin/main because removed code carried them). pre-commit run --all-files passes.
  • Parity evidence: see the #152 comment.

Before #152 can close (follow-ups, not in this PR)

  • workflow_dispatch smoke test against ~3 representative callers on this branch (clean repo, repo with a known HIGH like rag-processor, repo with .grype.yaml); confirm the Scan Runtime Dependencies check reports and gates.
  • Paired doc PR in ~/.claude: update docs/reference/renovate-architecture.md § "Relationship to SBOM Generation" (criterion 4).

Refs #152.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@williaby, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 11 minutes and 50 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 99505ad9-4789-4b1f-b38f-3b9bfb7eb378

📥 Commits

Reviewing files that changed from the base of the PR and between 06c5725 and 1ac5730.

📒 Files selected for processing (6)
  • .github/workflows/python-sbom.yml
  • CHANGELOG.md
  • scripts/compare_scanner_parity.py
  • tests/python/test_compare_scanner_parity.py
  • workflow-templates/python-release.yml
  • workflow-templates/python-sbom.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sbom-trivy-cutover-152

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

ESCALATE

Classification: substantive -- changes under .github/workflows/python-sbom.yml, workflow-templates/, and scripts/ place this PR outside all lighter classes regardless of its cleanup-heavy nature.

Escalation triggers:

  • breaking change marker in title (feat(python-sbom)!: ...)
  • workflow_call input removed (trivyignore-path): breaking change to caller interface
  • Total diff exceeds 500 lines (65 additions + 1 111 deletions; deleted script and test files are not lockfiles or generated files)

Checks performed (substantive class): logic errors, swallowed failures, expression injection into run: blocks, permission scope, secret handling, description-vs-diff consistency.

Findings

Severity File:location Issue
Important python-sbom.yml on.workflow_call.inputs trivyignore-path removed from caller interface; PR body asserts zero org callers pass it but the assertion is unverified by this review -- Tier 1 should independently confirm no org workflow YAML passes that input
Suggested python-sbom.yml scan-runtime-grype fail-build is now the sole merge gate; callers that set fail-on-vulnerabilities false receive an advisory-only Grype scan -- correct per design but worth a Tier 1 callout

No injection risk found. fail-build and severity-cutoff are passed via action with inputs, not run shell interpolation. Input values that reach shell steps go through env-var boundaries.

No permission widening. Promoted job retains contents:read + security-events:write. parity-summary job removal is a net reduction.

Description vs diff. All claimed changes (trivyignore-path removal, continue-on-error removal, if state-guard addition, fail-build promotion, job-name preservation, parity-summary and compare_scanner_parity.py deletion, CHANGELOG update) are confirmed in the diff.

Async reviewer status

  • CodeRabbit: reported (SUCCESS status context)
  • Copilot: not present in review list at review time

CI status

Completed and passing: Dependency Review, PR Title Format, Pre-Commit, Qlty Gate, REUSE Compliance, Security Analysis Gate, actionlint, shellcheck, Bats Tests, Python Tests, GitGuardian, Socket Security.

Still running at review time: CodeQL Analyze (python), SonarCloud Scan, Security Gate Validation (secondary run).

needs-deep-review label: already present on the PR -- no label add required.

@claude claude Bot added the needs-deep-review Queued for full pr-review skill pass label Jun 27, 2026
@williaby

Copy link
Copy Markdown
Collaborator Author

/pr-review findings — feat(python-sbom)!: cut over runtime CVE gate from Trivy to Grype (#152)

HEAD: d5b34d7 | CI: All PASS/SKIP | SonarCloud: 0 issues, 0 hotspots

PREMISE: CLEAN. The Trivy-to-Grype cutover is sound and necessary. The supply-chain rationale is well-documented in CHANGELOG. No files are unexpectedly deleted by this PR.


Critical

None.


Important

[IMP-1] workflow-templates/python-sbom.yml header comments are factually wrong after merge

workflow-templates/python-sbom.yml lines 5-9 (on main, not changed by this PR) currently read:

# Scans for vulnerabilities with Trivy (gating), Grype (advisory parallel-run),
#   and OSV-Scanner (gating, fast keyless SBOM-ingest gate)
# Uploads SARIF to GitHub Security tab (3 categories: trivy, grype, osv-sbom-runtime-deps)

After this PR merges every statement is wrong: Trivy is gone, Grype is gating (not advisory), and there are only 2 SARIF categories. This template file is the consumer-facing description of the workflow — callers read it to understand what they are enrolling in.

Fix: Update lines 5-9 to:

# Scans for vulnerabilities with Grype (gating) and OSV-Scanner (gating, fast keyless SBOM-ingest gate)
# Uploads SARIF to GitHub Security tab (2 categories: grype-runtime-deps, osv-sbom-runtime-deps)

Suggested

[SUG-1] workflow-templates/python-release.yml still shows Trivy as a recommended local scan tool

workflow-templates/python-release.yml line 209 includes a release-notes template block:

# Using Trivy
trivy sbom sbom-runtime.json

The PR's documented rationale is "Trivy release infrastructure compromised March 2026." Retaining Trivy as a recommended tool in release notes sends mixed signals to downstream users. Consider removing the Trivy example or adding a clarifying comment that the CI migration does not affect users' local Trivy installs.


[SUG-2] Smoke-test checkbox is open in the PR body

The pre-close checklist item workflow_dispatch smoke test against ~3 representative callers is unchecked. It is explicitly labeled as a follow-up (not a pre-merge blocker). Noting here to ensure it is tracked before closing issue #152.


[SUG-3] Missing #VERIFY on SARIF category / check-name continuity assumption

The name: Scan Runtime Dependencies rename (preserving required-status-check continuity) is a production-risk assumption. Per RAD tagging convention, add a #CRITICAL / #VERIFY comment pair alongside the name: field with a verification command such as gh api repos/OWNER/REPO/branches/main/protection/required_status_checks.


[SUG-4] Grype CVE database is downloaded twice per job

Two separate anchore/scan-action invocations (table-output + SARIF-output) each re-download the Grype database (~100 MB each). This is pre-existing behavior carried over from the advisory-mode job, not introduced here. Worth a follow-up but not a blocker.


[SUG-5] Dual fail-build behavior and step-level continue-on-error are undisclosed in PR body

The fail-build: ${{ inputs.fail-on-vulnerabilities }} delegation and the SARIF-upload step's independent continue-on-error: true are both correct but non-obvious to callers reading the PR description to understand the new failure semantics.


Informational

  • [INF-1] Removing job-level continue-on-error: true is intentional and net-positive for security visibility.
  • [INF-2] state=skip repos now skip Grype via if: guard, matching pre-existing Trivy behavior (bug fix, not regression).
  • [INF-3] Stale trivy-runtime-deps SARIF findings may persist in the Security tab until manually dismissed.
  • [INF-4] Copilot review not requested; CodeRabbit check passed but returned 0 comments.

Tier Count
Critical 0
Important 1
Suggested 5
Informational 4

The PR is mergeable. IMP-1 (stale template header) should be fixed in a companion commit or immediate follow-up PR.

Generated by /pr-review (Claude Sonnet 4.6)

williaby and others added 2 commits June 27, 2026 18:42
Promotes the Grype scan job to gating and removes Trivy, completing the issue #152 cutover. The parallel-run window confirmed package- and severity-level detection parity (Grype missed nothing Trivy caught, identical CVSS scores including HIGH findings).

Changes: remove the scan-runtime (Trivy) job; promote scan-runtime-grype to gating (fail-build mirrors fail-on-vulnerabilities, drop the job-level continue-on-error, add the SBOM-state guard the Trivy job had); the promoted job keeps the 'Scan Runtime Dependencies' check name so consumer rulesets are unaffected; remove the trivyignore-path input (verified no caller passes it); remove the parity-summary job and scripts/compare_scanner_parity.py plus its test. OSV-Scanner remains a second keyless gate.

Motivation: Trivy's release infrastructure was compromised in March 2026 with vulnerability DB updates suspended, making the scanner itself a supply-chain risk. Grype (Anchore) is unaffected.

BREAKING CHANGE: trivyignore-path input removed; use grype-config-path for CVE suppression. Gating scanner is now Grype, not Trivy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
workflow-templates/python-sbom.yml header still described Trivy as the
gating scanner and listed three SARIF categories (trivy, grype,
osv-sbom-runtime-deps). After the #152 cutover, Grype is the sole gating
scanner and only two SARIF categories remain (grype-runtime-deps,
osv-sbom-runtime-deps).

workflow-templates/python-release.yml release-notes template still offered
trivy sbom as a suggested local scan command. Removed it because the
CHANGELOG documents Trivy's March 2026 supply-chain compromise as the
migration rationale; recommending Trivy to downstream users after flagging
it as compromised sends mixed signals.

Closes the IMP-1 and SUG-1 findings from /pr-review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@williaby
williaby force-pushed the claude/sbom-trivy-cutover-152 branch from d5b34d7 to 1ac5730 Compare June 28, 2026 01:42
@sonarqubecloud

Copy link
Copy Markdown

@williaby
williaby added this pull request to the merge queue Jun 28, 2026
Merged via the queue into main with commit 64ad9cf Jun 28, 2026
44 checks passed
@williaby
williaby deleted the claude/sbom-trivy-cutover-152 branch June 28, 2026 01:48
williaby added a commit that referenced this pull request Jun 30, 2026
Fixes a collection of security and correctness gaps across promote-core,
consume-verify, and mirror-verify.

supply-chain-promote-core.yml:
- Fix Snyk dead gate: if: env.SNYK_TOKEN != '' evaluated step-level env which
  GHA never exposes to if: expressions; Snyk never ran. Add check-snyk-token
  step writing has-token to step outputs and gate on steps output (correct).
- Pin Snyk CLI to SNYK_CLI_VERSION; remove || true output suppression.
- Add masking for AUTH_B64 and AUTH_HEADER after GH_TOKEN masking; the log
  scrubber masks exact strings only and does not redact base64 derivatives.
- Add source_ref digest shape-guard before crane pull to enforce the verified
  digest trust model (rejects mutable tags).
- Add lock_file path traversal guard before any git operations on the file.
- Change workflow-level permissions from contents: read to {}.
- Add CRITICAL RAD marker on the Trivy re-introduction (Trivy was removed in
  PR #229 due to confirmed supply-chain compromise; this re-introduction requires
  ADR-012 and documented re-vetting before merge -- human action required).

supply-chain-consume-verify.yml:
- Propagate lock membership failure to the verified output in WARN mode: a
  digest not in the lock wrote only a warning and exited 0, then cosign could
  write verified=true, masking the lock failure. Now lock-check step outputs
  lock_passed; verify step demotes verified to false when lock failed.
- Fix expected_issuer_regexp default to anchored and dot-escaped form; an
  unescaped dot matched any character in the issuer URL.

supply-chain-mirror-verify.yml:
- Fix semantic inversion: when require_upstream_signature=false the output
  contract documents true when verified OR not required, but code wrote
  verified=false. Change to verified=true.
- Add UPSTREAM_REGISTRY and UPSTREAM_NAME shape-guards before GITHUB_OUTPUT
  writes to prevent newline injection into the output file.
- Fix expected_issuer_regexp default to anchored and dot-escaped form.
- Change workflow-level permissions from contents: read to {}.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
williaby added a commit that referenced this pull request Jul 2, 2026
The v1 tag froze at the v1.1.0 commit (6f71aec) when the org
tag-protection ruleset made all v* tags immutable, while main advanced
to v7.0.1. Docs still sold v1 as a moving tag, renovate.json followed
it (freezing SHA-pin updates), the starter templates and this repo's
own scorecard/security-analysis callers were SHA-pinned to the frozen
commit, and @v1 callers silently ran v1.1.0-era code, including the
Trivy scanner that PR #229 replaced after Trivy's release
infrastructure was compromised.

Commit fully to point-tag/SHA pinning (CI-005):

- renovate.json: drop followTag "v1" so Renovate advances org workflow
  SHA pins to the latest immutable release tag
- USAGE_EXAMPLES.md: rewrite Version Pinning around @<sha> # vX.Y.Z
  (recommended, Renovate-managed) and immutable @vX.Y.Z point tags
- CHANGELOG.md: correct the intro that claimed v1 is re-pointed as
  changes land; document the retirement under Unreleased
- sweep all @v1 usage examples (workflow headers, docs/workflows,
  examples, migration guides, READMEs) to the v7.0.1 SHA pin form
- bump workflow-templates/*.yml and this repo's scorecard.yml and
  security-analysis.yml off the frozen 6f71aec pin to v7.0.1
- add no-floating-v1 pre-commit guard (scripts/check-no-floating-v1.sh)
  blocking org-workflow @v1 references and followTag reintroduction

Intentionally untouched: tests/fixtures (negative fixtures),
tests/libs (vendored), docs/audits (historical record), and
third-party action examples (qlty-action, pr-size-labeler).

The stale v1 tag itself is deleted separately by an org admin; tag
deletion requires a ruleset bypass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
github-merge-queue Bot pushed a commit that referenced this pull request Jul 2, 2026
* fix(supply-chain): retire the frozen v1 floating tag

The v1 tag froze at the v1.1.0 commit (6f71aec) when the org
tag-protection ruleset made all v* tags immutable, while main advanced
to v7.0.1. Docs still sold v1 as a moving tag, renovate.json followed
it (freezing SHA-pin updates), the starter templates and this repo's
own scorecard/security-analysis callers were SHA-pinned to the frozen
commit, and @v1 callers silently ran v1.1.0-era code, including the
Trivy scanner that PR #229 replaced after Trivy's release
infrastructure was compromised.

Commit fully to point-tag/SHA pinning (CI-005):

- renovate.json: drop followTag "v1" so Renovate advances org workflow
  SHA pins to the latest immutable release tag
- USAGE_EXAMPLES.md: rewrite Version Pinning around @<sha> # vX.Y.Z
  (recommended, Renovate-managed) and immutable @vX.Y.Z point tags
- CHANGELOG.md: correct the intro that claimed v1 is re-pointed as
  changes land; document the retirement under Unreleased
- sweep all @v1 usage examples (workflow headers, docs/workflows,
  examples, migration guides, READMEs) to the v7.0.1 SHA pin form
- bump workflow-templates/*.yml and this repo's scorecard.yml and
  security-analysis.yml off the frozen 6f71aec pin to v7.0.1
- add no-floating-v1 pre-commit guard (scripts/check-no-floating-v1.sh)
  blocking org-workflow @v1 references and followTag reintroduction

Intentionally untouched: tests/fixtures (negative fixtures),
tests/libs (vendored), docs/audits (historical record), and
third-party action examples (qlty-action, pr-size-labeler).

The stale v1 tag itself is deleted separately by an org admin; tag
deletion requires a ruleset bypass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(supply-chain): harden the no-floating-v1 guard and cover it with bats

Strengthen the guard added for the v1 tag retirement:

- widen the pattern from @v1 to any bare @vn major (a future @v7 would
  freeze callers the same way) and match the org name case-insensitively,
  since GitHub resolves uses: owners case-insensitively
- fail closed: route the staged-file listing through a temp file so a
  git failure cannot read as "no staged files", and treat grep exit >= 2
  (unreadable file) as a hook failure instead of a silent pass
- extend the followTag check to all Renovate config basenames
  (renovate.json5, .renovaterc variants), tolerate unquoted JSON5 keys,
  and line-anchor the key match so prose like "No followTag: ..." in a
  rule description does not trip the guard (caught by the guard itself
  blocking this very commit)
- anchor renovate.json matchPackageNames as regex patterns so the rule
  cannot match forks or lookalike repos
- clarify in USAGE_EXAMPLES that the # vX.Y.Z release comment is not
  part of the uses: path
- add tests/check-no-floating-v1.bats (16 cases: bare-major blocking,
  allowed pin forms, path exclusions, followTag key variants vs prose,
  fail-closed git behavior) and correct the CLAUDE.md script/coverage
  inventory, which had also drifted on sync-secrets.bats

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(hooks): use structural context for the followTag key match

The line-anchored key match missed compact single-line JSON
({"followTag": "v1"}), where the key sits mid-line; bats cases 10-11
caught the false negative. Match on structural context instead: a real
key is preceded by an object opener, a separator, or line start
({, comma, or ^), while prose like "No followTag: ..." in a rule
description is preceded by a word and space, so both false positives
and false negatives are covered.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-deep-review Queued for full pr-review skill pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant