fix(audit): eliminate 11 CRITICAL false positives at the source (no suppression)#130
Open
cryptoxdog wants to merge 1 commit into
Open
fix(audit): eliminate 11 CRITICAL false positives at the source (no suppression)#130cryptoxdog wants to merge 1 commit into
cryptoxdog wants to merge 1 commit into
Conversation
…uppression)
tools/audit_engine.py --strict reported 11 CRITICALs that audit-pr-review.yml
already acknowledged as false positives via LEGACY_BASELINE. Rather than
suppress them, fix the real causes so the scanner is correct:
Rule 11 (FastAPI import / chassis isolation) — the audit allowlist was narrower
than the documented C-01 contract (AGENTS.md) and the compliance.yml gate.
Introduce a single _fastapi_import_allowed() helper matching C-01: api/, main.py,
handlers.py, app/middleware/, app/bootstrap/ (chassis bootstrap, INV-ARCH-03),
app/core/auth.py, app/score/score_api.py. Clears C-201..C-205 (auth.py,
rate_limiter.py, score_api.py, l9_contract_runtime.py — all governance-permitted
transport-adjacent modules). Also add app/bootstrap/* to the chassis-isolation
allowlists in compliance.yml and pr-pipeline.yml so all gates agree.
Rule 10 (f-string SQL) — the regex matched SQL verbs anywhere in a string,
misflagging prose ("...leads drop out...") in simulation_bridge.py. Require the
verb at the START of the f-string literal. Clears C-101.
Rule 2 (flatcase) — the heuristic flagged ANY long single word. Add a
word-break check (_looks_like_flatcase) that only flags names decomposing into
2+ known word tokens, so genuine flatcase ("accountnumber") is caught while
valid single words ("recommendation", "configuration") pass. Clears C-001..C-004.
salesforce_client.py — refactor the (already injection-safe, fully validated)
SOQL construction from an f-string to explicit concatenation of validated parts,
making the safe construction evident and removing the f-string-SQL pattern.
Clears C-102.
Verified: audit_engine.py --strict -> 0 CRITICAL, 0 HIGH (215 MEDIUM/964 INFO
unchanged); flatcase heuristic unit-checked against 10 valid words + 6 real
concatenations; chassis-isolation gate passes; ruff check/format clean.
Co-authored-by: Igor Beylin <cryptoxdog@users.noreply.github.com>
PR Size Report
✅ PR size is within recommended limits |
L9 Audit ReviewStatus
Policy
Blocking Findings
Advisory Findings
... truncated 1154 additional findings ... Generated by L9 Audit Engine ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
python tools/audit_engine.py --strict(agent-check gate 6) reported 11 CRITICAL findings that .github/workflows/audit-pr-review.yml already acknowledged as false positives via itsLEGACY_BASELINE. Per the directive, these are fixed at the source — the scanner's buggy heuristics are corrected and the one real code smell is refactored — rather than suppressed with ignore-annotations or a baseline.Fixes by rule
Rule 11 — FastAPI import / chassis isolation (clears C-201..C-205)
The audit allowlist (
api/,main.py,handlers.py) was narrower than the documented C-01 contract in AGENTS.md and the .github/workflows/compliance.yml gate, so it flagged governance-permitted transport-adjacent modules. Introduced a single_fastapi_import_allowed()helper matching C-01:api/,main.py,handlers.py,app/middleware/,app/bootstrap/(chassis bootstrap, INV-ARCH-03),app/core/auth.py,app/score/score_api.py. Also addedapp/bootstrap/*to the chassis-isolation allowlists incompliance.ymlandpr-pipeline.ymlso all gates agree on one source of truth (previously those gates also failed onl9_contract_runtime.py).Rule 10 — f-string SQL (clears C-101)
The regex matched a SQL verb anywhere in a string, misflagging prose (
"...unqualified leads drop out...") insimulation_bridge.py. Now requires the verb at the start of the f-string literal, where real query strings begin.Rule 2 — flatcase (clears C-001..C-004)
The heuristic flagged any long single word. Added a word-break check (
_looks_like_flatcase) that only flags names decomposing into 2+ known word tokens — so genuine flatcase (accountnumber→account+number) is caught while valid single words (recommendation,configuration,classification, ...) pass.salesforce_client.py— real refactor (clears C-102)The SOQL was already injection-safe (object type + field names validated against
_SOQL_FIELD_RE, values escaped via_soql_literal(), sent through the RESTqparam). Refactored the construction from an f-string to explicit concatenation of the validated parts, making the safe construction evident and removing the f-string-SQL pattern.Verification
python tools/audit_engine.py --strict→ 0 CRITICAL, 0 HIGH (215 MEDIUM / 964 INFO unchanged — those are not--strict-blocking).False; 6 real concatenations returnTrue.app/bootstrap/) → no violations.ruff check+ruff format --checkclean;py_compileclean.tests/compliance/+tests/ci/: 39 pass. The single failure (test_deprecated_compatibility_artifacts...needingREPO_MAP.mdat root) is unrelated to this PR and is resolved by the docs-to-root PR.Scope / tier
tools/audit_engine.py(T2),.github/workflows/*(T2),app/services/crm/salesforce_client.py(T3, engine service). No transport/schema (T4/T5) files touched.