Skip to content

tests: security_auditing tests call the real code, not inline copies (Part of #8434) - #8620

Merged
squid-shepherd[bot] merged 1 commit into
mainfrom
test/8434-security-auditing-reimpl
Nov 18, 2026
Merged

squid-shepherd[bot] merged 1 commit into
mainfrom
test/8434-security-auditing-reimpl

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #8434 (slice 3 of 4: tests/security_auditing/*; slices 1-2 merged in #8619).

What changed

Swept all 37 files in tests/security_auditing/ (grep for manually/mirror/simulate/replicate/inline, then read each hit) for tests that rebuild production logic inline.

  • test_security_auditor.py::test_construct_feature_matrix_nan_handling: it built the matrix with _construct_feature_matrix, then re-typed the reindex(fill_value=np.nan) and replace([inf,-inf], nan) lines from audit_repository and asserted on its own copy. It now runs the real audit_repository with a mocked model and asserts on the matrix predict_proba actually received.
  • test_security_lens.py::_safe_content: its docstring said "Mirror of scan_content's ReDoS-armored haystack construction". It also differed from the real one (dropped long lines instead of emptying them). It now calls SecurityLens._armor, the function scan_content uses.

Mutation check

  • Real code security_auditor.py:166 replace([inf,-inf], np.nan) changed to 0.0: test_construct_feature_matrix_nan_handling FAILS (before: passed, the copy was unaffected).
  • Same file :163 fill_value=np.nan changed to 0.0: the test FAILS.
  • Lens _armor change (keep long lines): test_signature_gates_are_one_sided still passes. Honest note: that test uses the armor on both sides of its gate-vs-regex comparison, so it is consistent under any armor. The end-to-end guard is test_gated_scan_content_matches_ungated (already calls scan_content). This edit removes a drifting copy; it is not a new detector of a mutation.

Gates: pr_gates.py --fast 9/9 pass; both touched files 101 passed, 1 skipped (selfscan venv, numpy/pandas/xgboost present). Ratchets not run (tests-only change, no engine, golden or ledger input).

Class / Sibling gaps

Class: tests that re-implement the code under test inline (a local copy of a production step, asserted instead of calling it). Members swept in tests/security_auditing/: 37 files; 2 re-implementers found and fixed here (above); the other 35 call the real functions (the "mirror" hits were corpus prose, "simulate" hits in test_pii_leak_hunter.py, test_api_network_map.py, test_supply_chain_firewall.py and test_security_lens.py:137 feed inputs or fault-inject through the real code).
Sibling gaps (not fixed here; no issues filed):

  • tests/tools/* sweep: not done (remaining slice 4 per the issue table).
  • tests/core_engine Active Hemorrhage post-hoc reimplementation (test_galaxyscope.py:1366): covered by slices 1-2 or slice 4; not re-checked here.
  • test_supply_chain_firewall.py feeds a shape the CLI no longer reads: tracked by the CLI issue in the epic, not a re-implementation.

Remaining slices

  • tests/tools/*: grep for manually/mirror/local helper copies of production logic (not touched here).

🤖 Generated with Claude Code

@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 18, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review November 18, 2026 17:28
@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) November 18, 2026 17:29
@squid-shepherd
squid-shepherd Bot merged commit 89e7272 into main Nov 18, 2026
57 checks passed
@squid-shepherd
squid-shepherd Bot deleted the test/8434-security-auditing-reimpl branch November 18, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant