Skip to content

refactor(security): the scanners stop looking for mocks, and their tests run on the scanner fake - #2551

Merged
dan-petty merged 3 commits into
mainfrom
test/2542-scanners-stop-mock-detection
Oct 28, 2026
Merged

dan-petty merged 3 commits into
mainfrom
test/2542-scanners-stop-mock-detection

Conversation

@dan-petty

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

Copy link
Copy Markdown
Owner

security/base.py searched sys.modules for a patched is_dry_run, check_binary or run_subprocess and called it in place of the real function. _check_binary also said a scanner's program was installed whenever a test had patched run_subprocess. Seven scanner modules re-imported run_subprocess, is_dry_run or shutil with # noqa: F401 only to be patch targets. AGENTS.md rule 2 forbids product code that detects tests.

This is part 1 of #1332. #2543, #2544 and #2545 carry the rest. ai/review/pipeline.py keeps its own NonCallableMock check, which #1328 owns.

Closes #2542

Change: openspec/changes/archive/2026-10-28-2542-scanners-stop-mock-detection/

@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence:

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

…sts run on the scanner fake

`security/base.py` searched `sys.modules` for a patched `is_dry_run`,
`check_binary` or `run_subprocess` and called it in place of the real
function, and seven scanner modules re-imported `run_subprocess`,
`is_dry_run` or `shutil` only to be patch targets. Product code that
detects tests is forbidden (AGENTS.md rule 2).

The `NonCallableMock` import, `_is_mocked`, `_patched_run_subprocess`,
the mock-aware branches and the re-imports are gone. A scanner asks
`is_dry_run()`, `check_binary()` and its tool executor directly.

The 63 patch sites that relied on them now use `scanner_fake`, a PATH
without the program, or `set_dry_run`. `ToolExecutorFake` and
`ScannerFake` gain `fail(tool, error)` and `answer_with(tool,
responder)`, and `docs/TESTING.md` describes them.
…nt on PATH through the scanner fake, not a patch the scanner looked for
@dan-petty
dan-petty force-pushed the test/2542-scanners-stop-mock-detection branch from a7106c4 to 58186f0 Compare October 28, 2026 22:01
@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 22:46
@dan-petty
dan-petty merged commit 2b7f37a into main Oct 28, 2026
26 of 28 checks passed
@dan-petty
dan-petty deleted the test/2542-scanners-stop-mock-detection branch October 28, 2026 23:16
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

Development

Successfully merging this pull request may close these issues.

test(security): the scanners stop looking for mocks, and their tests run on the scanner fake

1 participant