Skip to content

feat(cli): add --min-grade flag for configurable CI exit threshold#55

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-0z5C6
Open

feat(cli): add --min-grade flag for configurable CI exit threshold#55
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-0z5C6

Conversation

@dmchaledev
Copy link
Copy Markdown
Contributor

$(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-grade flag that accepts any valid grade (A+, A, B,
C, D, F) and exits with code 1 whenever the site's grade falls
below that threshold.

# Fail unless the site scores B or better
security-headers https://example.com --min-grade B

# Fail on D/F only (unchanged default behaviour)
security-headers https://example.com            # default: --min-grade C

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 against VALID_GRADES,
    replace the hard-coded grade === 'D' || grade === 'F' check with a
    rank-based comparison, and update --help output + examples.

Test plan

  • npm test — all 82 existing tests pass (library is unchanged)
  • security-headers https://example.com --help shows the new flag
  • --min-grade B exits 1 when a C-grade site is scanned
  • --min-grade C (default) exits 0 for a C-grade site
  • Invalid grade (e.g. --min-grade Z) prints a clear error and exits 1

https://claude.ai/code/session_016KofvKuoo4haZ8raNTwChF
EOF
)


Generated by Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants