feat(cli): add --fail-on flag for CI/CD gating on new CVEs#49
Merged
Conversation
The package is marketed for "CI/CD gates" but the CLI always exited 0, making it impossible to fail a pipeline on risky dependency changes. Add --fail-on none|any|low|medium|high|critical. When new CVEs meet the chosen severity policy the report is still printed and the process exits with code 3 (distinct from usage/runtime errors). Default `none` keeps the prior always-exit-0 behaviour, so this is backward compatible. Includes unit tests for parsing and gate evaluation, plus README and CHANGELOG updates. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BtfgewzoZwjEmGChLPtzHy
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
The package README markets
sbom-diffas "perfect for CI/CD gates and audit trails," but the CLI always exited with code0no matter what the diff found. That makes the primary advertised use case — failing a pipeline when a risky dependency change is introduced — impossible without extra scripting to parse the output.Change
Add a
--fail-onflag that turns the diff into a pass/fail gate:--fail-onnone(default)0anylow/medium/high/criticalWhen the policy is triggered, the report is still printed to stdout and a short reason is written to stderr, and the process exits with code
3(deliberately distinct from the1used for usage/runtime errors, so CI can tell a policy failure from a crash).Notes
none, preserving the prior always-exit-0behaviour. Existing--formathandling and output are unchanged.anygate, since it can't be compared against a severity threshold.parseArgsand the new puregateFailures()helper are unit-tested (9 new tests: flag parsing, threshold selection, unknown-severity handling). Full suite: 38 passing.lint,tsc --noEmit, andbuildall clean.Files
src/cli.ts—--fail-onparsing,gateFailures(), exit-code logicsrc/__tests__/cli.test.ts— parsing + gate-evaluation testsREADME.md,CHANGELOG.md— documentation🤖 Generated with Claude Code
https://claude.ai/code/session_01BtfgewzoZwjEmGChLPtzHy
Generated by Claude Code