feat(cli): warn when --fail-on gate can't see any vulnerability data#54
Open
dmchaledev wants to merge 1 commit into
Open
feat(cli): warn when --fail-on gate can't see any vulnerability data#54dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
The --fail-on gate only evaluates vulnerabilities embedded in the compared SBOMs (diff() derives newCVEs from each SBOM's `vulnerabilities` list). Most SBOMs carry none: SPDX 2.x has no vulnerability field, and the default output of common CycloneDX generators omits one. In that case the gate has nothing to evaluate and always passes — a silent fail-open that reads as "no new CVEs" in CI when the truth is "CVEs were never checked". Add gateWarning(oldSBOM, newSBOM, failOn): when a gate is armed (failOn !== 'none') but neither SBOM carries vulnerability data, main() prints a warning to stderr explaining why the gate can't fire and how to enable it. The report still goes to stdout and the exit code is unchanged, so nothing breaks for callers whose SBOMs do embed vulnerabilities. Covered by six new unit tests; README --fail-on section and CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0142u9rtNkQzJmMuxzjuDbZV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
--fail-onis the headline CI/CD gate, but it can only evaluate vulnerabilities that are embedded in the SBOMs being compared —diff()derivesnewCVEsfrom each SBOM'svulnerabilitieslist (src/diff.ts:41-44), andgateFailures()filters that list (src/cli.ts).Most real-world SBOMs carry no such data:
parseSPDX()hardcodesvulnerabilities: [](src/parser.ts:79).vulnerabilitiesarray; vulnerabilities are usually attached later by a separate scan/VEX step.When a gate is armed against such inputs,
newCVEsis always empty, so the gate always passes and the process exits0. In CI this reads as "no new CVEs" when the truth is "CVEs were never checked" — a silent fail-open in a security tool.Fix
Add
gateWarning(oldSBOM, newSBOM, failOn): when a gate is armed (failOn !== 'none') but neither SBOM carries vulnerability data,main()prints a warning to stderr explaining why the gate can't fire and how to enable it. The report still goes to stdout and the exit code is unchanged, so behavior is fully preserved for callers whose SBOMs do embed vulnerabilities — and for the default--fail-on none.Example (gate armed, no vuln data — note the report and exit code are untouched; only the stderr warning is new):
Changes
src/cli.ts— new exportedgateWarning(), wired intomain()(stderr only).src/__tests__/cli.test.ts— 6 new unit tests covering: gate off, armed with no data (any+ severity policies), old-side data present, new-side data present, and a missingvulnerabilitiesfield.README.md— note under the--fail-onsection documenting the embedded-vulnerability precondition and the warning.CHANGELOG.md— Unreleased/Added entry.Verification
npx tsc --noEmit,npm run lint, andnpm testall pass (44 tests, +6). Manually verified end-to-end: warning fires on stderr for vuln-less inputs, stays silent when the gate is off or when either SBOM embeds a CVE.Scope
Deliberately narrow and additive — it does not change any exit code, gate semantics, or the report on stdout. It is independent of the in-flight purl-keying and VEX-suppression PRs; no overlapping files beyond the shared CLI test file.
Generated by Claude Code