feat(cli): add --min-grade flag for configurable CI exit threshold#55
Open
dmchaledev wants to merge 1 commit into
Open
feat(cli): add --min-grade flag for configurable CI exit threshold#55dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
The exit-code-1 threshold was hardcoded to D/F, making the tool too lenient for teams that want to enforce a stricter security bar (e.g. B or better) as a CI gate. --min-grade lets callers set any grade (A+, A, B, C, D, F) as the failure threshold; the default (C) preserves the existing behaviour. https://claude.ai/code/session_016KofvKuoo4haZ8raNTwChF
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.
$(cat <<'EOF'
Problem
The CLI's exit-code-1 threshold is hardcoded to grades D and F. Teams
that want to enforce a stricter security bar — e.g. "our CI pipeline
must achieve B or better" — have no way to configure this. They either
get false-green (C slips through) or have to wrap the tool in a shell
script that re-parses the JSON output.
Solution
Add a
--min-gradeflag that accepts any valid grade (A+,A,B,C,D,F) and exits with code 1 whenever the site's grade fallsbelow that threshold.
The default is
C, which preserves the existing behaviour exactly(exit 1 on D or F, exit 0 on C, B, A, A+).
Changes
src/cli.ts: parse--min-grade, validate it againstVALID_GRADES,replace the hard-coded
grade === 'D' || grade === 'F'check with arank-based comparison, and update
--helpoutput + examples.Test plan
npm test— all 82 existing tests pass (library is unchanged)security-headers https://example.com --helpshows the new flag--min-grade Bexits 1 when a C-grade site is scanned--min-grade C(default) exits 0 for a C-grade site--min-grade Z) prints a clear error and exits 1https://claude.ai/code/session_016KofvKuoo4haZ8raNTwChF
EOF
)
Generated by Claude Code