Skip to content

Feat: Add grype_enabled input to skip the scan - #85

Merged
ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:feat/add-grype-enabled-toggle
Sep 1, 2026
Merged

Feat: Add grype_enabled input to skip the scan#85
ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:feat/add-grype-enabled-toggle

Conversation

@ModeSevenIndustrialSolutions

@ModeSevenIndustrialSolutionsModeSevenIndustrialSolutions commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds grype_enabled (boolean, default: true) to all four lanes, so callers can skip the Grype scan without losing the SBOM — and hardens the release gates so a skipped scan cannot be confused with a failed one.

Why

Nothing in the estate could skip Grype. The job hung off the SBOM job:

grype:
needs: 'sbom'if: ${{ !cancelled() && needs.sbom.result == 'success' }}

So the only escape hatch was sbom_enabled: false, which skips the SBOM and silently takes Grype with it — exactly backwards, since SBOM generation is the part we want on by default. Any project that set sbom_enabled: false to get past a blocking CVE has been quietly shipping without an SBOM ever since.

grype_enabled decouples them. The decoupling is deliberately one-way: disabling the scan keeps the SBOM, but disabling the SBOM also stops the scan, which has nothing to read.

Changes

LaneGrype shapeGate applied to
build-testjobjob if:
build-test-releasejobjob if:
build-test-release-multiarchmatrixed jobjob if:
build-test-multiarchstep inside the matrixed sbom jobstep if:

That last row is a structural quirk of this repo worth flagging to reviewers — in build-test-multiarch Grype is not a separate job, so the gate lands on the step.

Also reworded the sbom_enabled description, which previously read "also skips the dependent Grype scan job" and implied a deliberate coupling.

Release gate hardening (added after review)

Both release lanes gated downstream jobs with:

contains(fromJSON('["success", "skipped"]'), needs.grype.result)

That accepts every skip as benign, but skipped is ambiguous. Grype skips both when a toggle disables it and when the sbom job fails — so a failed SBOM would have let python-tests and, more seriously, attach-artefacts proceed with no scan performed at all.

This idiom pre-dates this PR. It was latent because a skipped Grype previously required an SBOM failure; grype_enabled makes that state routine and configuration-reachable, so leaving it would mean shipping a known hole behind a newly-common path. Now:

&& (needs.grype.result == 'success'|| (needs.grype.result == 'skipped'&& (!inputs.grype_enabled || !inputs.sbom_enabled)))

A skip is accepted only when a toggle explains it. The Grype clause tests both toggles because either legitimately produces the skip. The same treatment is applied to the sbom and python-audit clauses, on both the python-tests and attach-artefacts gates in both release lanes. attach-artefacts matters most: that gate guards what actually gets released.

Credit to Copilot for spotting this on the companion PRs.

Compatibility

default: trueno existing caller changes behaviour. No inputs removed or renamed. The gate change is strictly more conservative: it can only block where it previously allowed, and only when a scan genuinely did not run.

Validation

  • yamllint, actionlint over all workflows and examples — clean
  • zizmor --persona=auditor — no new findings (the one self-repository help-level note in testing.yaml is pre-existing and estate-wide)
  • Full prek run over the changed files — all hooks passed

Follow-up

lfreleng-actions/workflows-template#57 tracks end-to-end coverage of the opt-out paths, which Copilot rightly asked for and which is deliberately not bolted onto this PR — the multiarch step-level gate is flagged there as the highest-priority case, being the structural outlier.

Context

Part of a seven-PR series standardising these toggles across the workflow estate. Companions: lfreleng-actions/workflows-template#56, lfreleng-actions/go-workflows#67, lfreleng-actions/node-workflows#83, lfreleng-actions/java-workflows#45, lfreleng-actions/docker-workflows#68.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an independent grype_enabled toggle across all reusable workflow lanes while preserving SBOM generation.

Changes:

  • Adds the boolean input with a backward-compatible true default.
  • Gates standalone Grype jobs and the multi-arch Grype step.
  • Documents the toggle in caller examples.
File summaries
FileDescription
.github/workflows/build-test.yamlAdds and applies the Grype toggle.
.github/workflows/build-test-release.yamlAdds release-lane Grype gating.
.github/workflows/build-test-multiarch.yamlGates the embedded Grype step.
.github/workflows/build-test-release-multiarch.yamlGates the matrixed Grype job.
examples/build-test/github.yamlDocuments the new inputs.
examples/build-test-multiarch/github.yamlDocuments multi-arch usage.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread.github/workflows/build-test.yaml
Comment thread.github/workflows/build-test-multiarch.yaml

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Nothing could skip the Grype scan. The job hung off the SBOM job
with 'needs.sbom.result == success', so the only way to avoid a
scan was to set sbom_enabled false and lose the SBOM with it.
Add grype_enabled (boolean, default true) to all four lanes so the
scan can be dropped while the SBOM is still generated, uploaded and
published. In the multiarch build-test lane Grype is a step inside
the matrixed sbom job rather than a separate job, so the gate lands
on the step there.
Reword the sbom_enabled description: Grype is skipped because it has
no SBOM to read, not because the two are deliberately coupled.
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@zxiirozxiiro left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Auto-approved by agent: reviewed workflow/code change for security and CI/CD impact, found low risk. Adds additive grype_enabled input defaulting to true across single- and multi-arch workflows. Defaults preserve current scans; no permission/secret/pin changes.

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 2b3f687 into lfreleng-actions:mainSep 1, 2026
74 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the feat/add-grype-enabled-toggle branch September 1, 2026 13:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ModeSevenIndustrialSolutions@zxiiro