Repository navigation
Conversation
…ml (#1738) Root: the Security Scanning job ran `bandit -r .` and exited with Bandit's any-finding status, ignoring the governed policy in .github/security/security.toml (severity/confidence medium, B101 waived in tests only, watch rules never suppressed). On main 4390fb9 that is 25,058 raw findings, 24,065 of them pytest asserts in tests, so the gate was red permanently and had to stay out of the required contexts. scripts/ci/bandit_policy_gate.py reads that policy and decides: - watch rules (B105, B106, B108, B201, B301, B302, B324, B506, B601, B602) block everywhere, tests included - other findings block at medium+ severity AND medium+ confidence - B101 is waived in test files only; other listed skips (B603) everywhere - exit 0 clean / 1 blocking / 2 unreadable report or policy (fail closed) The scan stays repository-wide and its raw report is unchanged; the decision JSON is uploaded beside it. On main 4390fb9: raw 25,058 -> blocking 183 (55 in code, 128 in tests): B105 73, B310 29, B314 27, B102 14, B108 13, B106 12, B602 6, B103 4, B506 3, B324 2. The gate stays red on those until each is fixed or adjudicated. 14 tests; the workflow step was replayed locally against the real report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RiTqsSEPVgsB1tgV1nng6C
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1706baab3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # tests only) instead of Bandit's any-finding exit status (#1738). | ||
| set +e | ||
| python scripts/ci/bandit_policy_gate.py bandit-report.json \ | ||
| --policy .github/security/security.toml \ |
There was a problem hiding this comment.
Trigger the gate for policy-only changes
The new --policy dependency is absent from both on.push.paths and on.pull_request.paths, so a commit changing only .github/security/security.toml never runs this security job. Moreover, scripts/ci_pr_debt_ratchet.py does not register this file as Bandit configuration, so in a mixed PR the enforcement block at lines 960-967 can ignore the gate's failed outcome when FULL_SCAN is not required. A malformed policy or a change to thresholds/watch rules can therefore take effect without being validated by the gate; add the policy to both path filters and the ratchet's Bandit configuration inputs.
Useful? React with 👍 / 👎.
| # (watch rules everywhere; medium+/medium+ otherwise; B101 waived in | ||
| # tests only) instead of Bandit's any-finding exit status (#1738). | ||
| set +e | ||
| python scripts/ci/bandit_policy_gate.py bandit-report.json \ |
There was a problem hiding this comment.
Treat the new gate as a Bandit environment input
Changes to scripts/ci/bandit_policy_gate.py trigger this workflow as Python changes, but the script is not listed in scripts/ci_pr_debt_ratchet.py's TOOL_ENVIRONMENT_FILES. Consequently, a semantic weakening of the classifier can pass the per-file Bandit ratchet, leave FULL_SCAN unset, and have its own gate outcome ignored by the enforcement block at lines 960-967. Register this new admission script as a Bandit environment input, just as the ratchet already protects itself from admitting its own weakening.
Useful? React with 👍 / 👎.
| if rule in TEST_ONLY_SKIPS and rule in policy["skips"] and in_tests: | ||
| return "waived_test_only_skip" | ||
| if rule in policy["watch"]: |
There was a problem hiding this comment.
Check watch rules before test-only skips
If a rule such as B101 remains in [bandit.skips] while being promoted into [bandit.watch], a finding in a test file returns waived_test_only_skip before the watch membership is checked. That contradicts this gate's stated invariant that watch rules block everywhere and makes the natural policy edit of adding a rule to watch ineffective unless the editor also knows to remove it from skips; evaluate policy["watch"] first.
Useful? React with 👍 / 👎.
PR Decision Brief
Purpose / why: Turn Security Scanning from a permanent red into a gate that can be required, as #1738 asks (Bandit findings classified, with a disposition per class).
Before -> after: Before, the job runs
bandit -r .and exits on Bandit's any-finding status. On main4390fb9that is 25,058 findings, of which 24,065 are pytestasserts in tests, and the job is red on every run. After, the same repository-wide scan runs, and blocking follows the policy that.github/security/security.tomlalready declares. Result: 183 blocking findings (55 in code, 128 in tests), each listed inbandit-policy-decision.json.Scope / excluded work:
scripts/ci/bandit_policy_gate.py(new), its tests, and theRun Banditstep plus artifact list inci-cd-tests.yml.-r .), the raw report,bandit_report_guard.py, the new-debt ratchet, Safety,security.tomlitself.Related issue, parent wave or dependency: #1738. It's on the C-PATH admission path: Bandit → #1738 → MAIN-GREEN → #1860.
1. Verification (do not guess)
Admission: HOLD until separately verified under the effective ruleset.
tests/test_bandit_policy_gate.py14 passed. Covers classification per policy branch, test-path recognition, ordering, exit codes 0/1/2, a bad report, a bad or missing policy, and the committed policy loadingraw=25058 blocking=183 blocking_in_code=55, step exit 1,exit_codeoutput kept for downstream stepsFirst red / blocker / owner: Account billing lock (owner). After that, the gate stays red on the 183 policy-blocking findings, which is intended.
2. Risk and reviewer decision
Risk and rollback:
security.tomlchange, reviewed on its own.Focus for independent review:
security.toml?tests/,testing/,test_*.py,*_test.pyandconftest.py.Next action / named owner: Security owner reviews the policy reading. After merge, burn the 183 down by rule lane.
3. Optional machine evidence projection
Not yet populated. This section is informational and cannot grant merge admission.
Generated by Claude Code