Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ One finding per vulnerable site, never a group or a range: each state-changing c

Fixed class vocabulary: `missing-authn`, `missing-authz`, `object-level-authz`, `ssrf`, `tls-off`, `outbound-timeout`, `secret-in-url`, `secret-in-log`, `hardcoded-secret` (credentials or tokens in source), `csrf`, `cookie-flags`, `rate-limit`, `pii-in-log`, `pii-data` (personal data committed, stored in plaintext or sent to a third party), `prompt-injection` (including tool-call JSON built from input), `injection`, `xss`, `other`. Pick the closest class; use `other` only when none fits.

Cite the sink: for `ssrf`, `tls-off`, `outbound-timeout` and `secret-in-url` the outbound call, URL or TLS option; for `secret-in-log` and `pii-in-log` the log call; for `cookie-flags` the cookie set. The lint fails a cite whose line +-2 shows no sink (`finding-not-on-sink`). One finding per issue: do not re-cite it at the route or a helper. `rate-limit` cites the handler line only, and only for brute-forceable or costly endpoints (login, PIN, OTP, SMS, LLM, bulk export); not when a limiter already wraps the route. `csrf`: SameSite Lax or Strict blocks a cross-site POST but not a state-changing GET. Never cite a token generator or a limiter definition. A `pii-in-log` line that logs a key, token, secret or password is `secret-in-log`; one with an outbound call and no log call is `pii-data` (`class-mismatch`).

Example: `- [pii-data] src/api/users.py:42 high: serves SSNs and dates of birth unmasked. evidence: src/models.py:10`

## Rules the linter enforces
Expand Down
29 changes: 29 additions & 0 deletions .claude/skills/deep-code-review/scripts/report_contract_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
"missing-authn", "missing-authz", "object-level-authz", "ssrf", "tls-off", "outbound-timeout", "secret-in-url", "secret-in-log",
"hardcoded-secret", "csrf", "cookie-flags", "rate-limit", "pii-in-log", "pii-data", "prompt-injection", "injection", "xss", "other",
}
I = re.I
OUT = re.compile(r"https?://|fetch\w*\(|\w*request\w*\(|requests\.|axios|curl|urlopen|reqwest|openConnection|openStream|resttemplate|webclient|httpclient|file_get_contents|fopen|got\(|\bopen\(|okhttp|\b(?:client|session|http|agent)\w*\.\w+\(|\bhttp\w*\.", I) # outbound call or URL
LOG = re.compile(r"\b(?:log|logger|logging|slog|console)\b|\bprint|puts|fmt\.|\becho\b|var_dump|error_log|\b(?:debug|warn|warning|error|info|trace)\s*\(", I)
COOKIE = re.compile(r"cookie|httponly|samesite|session", I)
TLS = r"verify|ssl|tls|timeout|insecure|rejectUnauthorized"
SINKS = {c: (OUT.pattern + "|" + TLS + x, "outbound HTTP call, URL or TLS option") for c, x in
(("ssrf", ""), ("outbound-timeout", ""), ("tls-off", "|trust|verif|cert|hostname"), ("secret-in-url", r"|[?&]\w+="))}
SINKS.update({c: (LOG.pattern, "log or print call") for c in ("secret-in-log", "pii-in-log")})
SINKS["cookie-flags"] = (COOKIE.pattern, "cookie set or cookie config")
CRED = re.compile(r"(?<![a-z])(?:api_?key|access_?key|secret|token|password|passwd|pwd)(?![a-z])", I)
PII = re.compile(r"(?<![a-z])(?:email|phone|ssn|dob|birth|address|name|user|ip)s?(?![a-z])", I)
FINDING = re.compile(r"\[([\w-]+)\]\s+(\S+)\s+[\w-]+:\s*\S")
FILES_SPLIT = r"[;\s]+|,(?![\d-]+(?:[,;\s]|$))" # a comma before a bare line number continues `path:1,2`
STATUSES = {"pass", "fail", "not-checked"}
Expand Down Expand Up @@ -115,6 +126,22 @@ def resolve(tok, root):
return full, a, b, None


def sink_problem(cls, full, a, b):
"""Rule text when the cited line (+-2) is off the class's sink, or the class mismatches the line; else None."""
lines = open(full, errors="replace").read().splitlines()
one = lines[a - 1]
win = "\n".join(lines[max(a - 3, 0):(b or a) + 2])
if cls == "pii-in-log":
if LOG.search(win) and CRED.search(one) and not PII.search(one):
return "class-mismatch", "logged value names a credential (key/token/secret/password): use secret-in-log"
if OUT.search(one) and not LOG.search(win):
return "class-mismatch", "line is an outbound call, not a log call: use pii-data"
if cls in SINKS:
rx, what = SINKS[cls]
if not re.search(rx, win, I):
return "finding-not-on-sink", f"[{cls}] cited line +-2 shows no {what}: cite the sink line, not the route/helper"


def lint(path, root, text=None):
raw = (text if text is not None else sys.stdin.read() if path == "-" else open(path, errors="replace").read()).splitlines()
live, fence = [], False # fenced lines are blanked, indexes preserved
Expand Down Expand Up @@ -167,6 +194,8 @@ def body(n): # lines of heading n, up to the next heading of equal or higher le
add(k, "bad-citation", err)
elif "," in m.group(2) or any(not resolve(c, root)[3] for c in re.findall(r"[\w/.-]+\.\w+:\d+", l[m.end() - 1:].split("evidence:")[0])):
add(k, "finding-multi-cite", "one primary path:line per finding; put other cites after `evidence:`")
elif ":" in m.group(2) and (sp := sink_problem(m.group(1).lower(), *resolve(m.group(2), root)[:3])):
add(k, *sp)
rows, in_table = [], set()
for n, (i, _, t) in enumerate(heads):
if not re.search(SECTIONS["missing-table"], t, re.I):
Expand Down
4 changes: 2 additions & 2 deletions SHA256SUMS
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ b7b85757362758f393b6ddaaafed0f8a5e5075c9a74b604d3a80fca0301bdd71 .claude/skills
0de8627b98293ea5f2b2869d6aac8ec6fd2015336dc4c2e17cd3c5b8f251455b .claude/skills/deep-code-review/references/ux-writes.md
034c0fe0b35fc11bc46b4ae8d3651ff80f9ed28d43b8aa3373927ba37ea6b23f .claude/skills/deep-code-review/references/web-fetch.md
b05798db39365a53e913dee3910c1193de2560b00ef2ed47c91ec1608ce2a96f .claude/skills/deep-code-review/references/web-render.md
3491796873a0c23acf2014b13a7db23b3c65b597628d90b547e207c4af1d1820 .claude/skills/deep-code-review/references/whole-project-report.md
f2bd147f71d95596efb1a75f5e4a896a2349623567daeeb3f4cc8fc976913fdf .claude/skills/deep-code-review/references/whole-project-report.md
a125d270e13807ed494e48746d374b82318e9e04eeeafb3db004729938dee039 .claude/skills/deep-code-review/scripts/app_pentest.sh
4a5ffb66e6f636f15085c4edc5f02ce9ae7513b5292467d249fd9fa34f32e1ee .claude/skills/deep-code-review/scripts/attempt_limit_map.py
b4d0333271317c881d175dca1d06092cc1dd4859e33f0b375eb870a152a80e6c .claude/skills/deep-code-review/scripts/binaries_gate.py
Expand Down Expand Up @@ -404,7 +404,7 @@ e2903a566deee3423cc377b000475b30d6698ccebd640cb62b86b6d2001c4822 .claude/skills
5d6910164ddf6dfd4ed62dfc365a2f615f49dc07878ed3d1f881aa9518e481c2 .claude/skills/deep-code-review/scripts/post_review.sh
b01cae69d80ca560cc414c1c70ef0ddfdbb910da5b68df4e9d46cf0daf3f8b16 .claude/skills/deep-code-review/scripts/provision_tools.sh
e1d1d2eab715ef280b8c211a9da15ebe6b87969de89d7028d7f1cc82d64fc1f0 .claude/skills/deep-code-review/scripts/reaper_lint.py
97632d428fff3ba7b136573bc3447571c51069b284f2cabaa804c9871aee3151 .claude/skills/deep-code-review/scripts/report_contract_lint.py
364ce5842f6416741be9ca935164f3ea7c9d8fadc34ef8b1b7e845d684f25c86 .claude/skills/deep-code-review/scripts/report_contract_lint.py
249e3d744adaf7370e7dc6519a6b140ed7bbb4cbec825c75a3c42d519426c6fb .claude/skills/deep-code-review/scripts/review_checks.sh
8c87c02a050a975e453b52ecacbaf01481c7134466a9c67feaf409d22e36d9f7 .claude/skills/deep-code-review/scripts/review_feedback.py
28a7d9ff6311a400e340706e7d9e46c01b840c4275e602f3ecdd20a80659c222 .claude/skills/deep-code-review/scripts/route_auth_map.py
Expand Down
7 changes: 7 additions & 0 deletions changelog.d/report-lint-sink-precision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Added
- `report_contract_lint.py` rules `finding-not-on-sink` (a `ssrf`, `tls-off`, `outbound-timeout`, `secret-in-url`, `secret-in-log`, `pii-in-log` or `cookie-flags` finding whose cited line +-2 shows no matching sink) and `class-mismatch` (`pii-in-log` that logs a credential should be `secret-in-log`; one with an outbound call and no log call should be `pii-data`). Tests in `scripts/test_report_contract_lint_sink.py`.

### Changed
- `whole-project-report.md` tells the author to cite the sink, file one finding per issue, rate-limit only brute-forceable or costly handlers, and never cite token generators or limiter definitions.

size-budget-raise: .claude/skills/deep-code-review/references/whole-project-report.md 4772→5593 sink-citation and false-positive guidance for the class vocabulary
1 change: 1 addition & 0 deletions docs/bench/g6-data-api/ledger.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
{"ts": 1793739010, "iso": "2026-11-03T20:50:10Z", "event": "amended", "set": "set1", "reason": "independent review before any scored run: the answer key is deleted before the paid agent runs (it can Read $TMPDIR); a call with no result event is an error and books the whole call cap; the scorer refuses a bare call and stray positionals; the src concat recipe is stated exactly. The repo privacy gate blocked two seed national-id values in five extras files (valid-SSN shape), so their area digits moved to the never-issued 9xx range (same length, same lines, still under an `ssn` key); the rebuilt truth.json hashes identical. Build, truth and routes hashes are unchanged. For the repo bench_check gate, SHA256-frozen.txt now names each of the 75 src files (lines 6-80 at their registration-time hashes, which reproduce the registered src_concat 31d29e42) and the preregistered event carries the sha256 of those first 80 lines; both were derived after the fact from the registered content and nothing else in that event changed. The five changed extras files and the two fixed scripts are re-listed after line 80 with the new hashes below.","src_concat": "fa7a5e277df08a4f9c976c0e46b031a81c7c124c6c6d724cdc052790109a2cc8", "files": {"docs/bench/g6-data-api/run_and_score.py": "599543a442ee89bc0b4fe7d55bff7c740cb87446c93528b47af68335c6adb9f9", "docs/bench/g6-data-api/agentic_arm.py": "7b98a4ec073fe614e3c10df57f201af963d902926055b1b3f1b54b1c9013ff6f", "docs/bench/g6-data-api/set1/src/depot-go/extras.go": "efe73567bf48ab7a5fe6019319de5590ea75da4a7d9026f184d1f221119ab63f", "docs/bench/g6-data-api/set1/src/ledger-express/extras.js": "ede9811b2dd3d548049d5f6c98d8d8326217f5c7652c25ca28666f5919bb841f", "docs/bench/g6-data-api/set1/src/notes-next/lib/extras.ts": "26e1fd0859c72e775e3f6357a01bb1875e6b1a37f3695ef565a92986cda3f6cd", "docs/bench/g6-data-api/set1/src/scoreboard-flask/extras.py": "8793360c0701bdf9f399ee3b3231fae6e7f1ba6263c7d2b2b23e930bb78f5c60", "docs/bench/g6-data-api/set1/src/shop-spring/src/main/java/example/shop/ExtrasController.java": "025a80f9271145a990e8daa44a6f5871f6dbe51a124e4c9df8bc2f782faf51d1"}, "src_concat_cmd": "find docs/bench/g6-data-api/set1/src -type f | sort | xargs shasum -a 256 | shasum -a 256", "note": "commit ids named above are lane commits squashed into the landing PR"}
{"ts": 1793750170, "iso": "2026-11-03T23:56:10Z", "event": "run_started", "set": "set1", "landed": "d44fd0251 (#2214)", "detector": "343a07a3a exported with git archive (94260 files + 3 symlinks = 94263 tree entries)", "quota": "probe max utilization 0.64 (seven_day), five_hour 0", "preflight": "dry build of set1 has 0 @@ markers and no truth/routes files; run_and_score.py and agentic_arm.py match their last frozen lines", "early_stop_rule": "decided before the run: once this run starts it is the one scored attempt and set1 is burned. A fixture the driver does not finish (cap, quota, 429, crash) is scored NOT RUN by the frozen scorer and counts against the gate; set1 is never re-run", "contamination_rule": "before scoring, every transcript's tool_use inputs are scanned for paths outside the fixture and detector dirs; a read of the bench source, truth or another private truth marks the run contaminated, and it is recorded, not scored"}
{"ts": 1793751136, "iso": "2026-11-04T00:12:16Z", "event": "scored", "set": "set1", "verdict": "FAIL", "parts_passed": "0/8", "run": {"complete": true, "fixtures": "6/6", "errors": 0, "spent_usd": 1.218, "rows": 277}, "contamination": "clean: no tool_use input in any transcript names a path outside the fixture and detector dirs", "raw": "results-20261104T000455Z/score.json (sha256 3ce14cd4d6838d70): pass false, 7 parts pending_adjudication, 49 unmatched rows", "adjudication": "independent Sonnet reviewer, blind (dry build with 0 @@ markers and no truth or routes file), against the fixture source; 17 tp, 32 fp; results-20261104T000952Z/adjudicated.json (sha256 e103894d6e651c3d, scorer ignores the extra why field; re-scoring with it reproduces score.json exactly). The operator spot-checked 7 tp against the source", "final": "results-20261104T000952Z/score.json (sha256 1ce48e287eb02366). recall/precision: routes 26/34 0.76, 26/42 0.62; outbound 30/35 0.86 (pass), 30/39 0.77; rate_limit 3/14, 3/8; csrf 8/15, 8/15; cookie_flags 8/13, 8/9; pii_log 10/13, 10/13; pii_data 0/12, no rows; prompt_injection 7/13, 7/7", "route_inventory_g9": "77 of 227 listed routes found", "g0_lint": "report_contract_lint.py --root <fixture>: 1 of 6 reports clean; 85 bad-citation (mostly bare file names, plus comma line lists read as paths), 2 safety-claim, 1 guided pass with no cited file", "disclosures": ["shop-spring cites bare file names (StaffController.java, not src/main/java/...), so none of its 22 rows could match its 35 truth rows under scoring rule 8; its real findings entered only via adjudication", "rule 7 adds an adjudicated tp to positives and hits, so a real finding cited at a different line than its truth row (route registration vs handler) is counted twice: once as a missed truth row and once as a new hit", "raw transcripts are not committed because they hold local home paths; sha256 prefixes: depot-go dcaceb86a1c13183, ledger-express 029ab6050930b1b1, notes-next 35550f8d54fcaae8, scoreboard-flask df03d12a1e53b24e, shop-spring d492bc2512e1f71a, tickets-django 8d08622c2da44b21"], "next": "set1 is burned. Product root-cause lane (citations as repo-relative paths, pii_data, rate_limit, csrf, route inventory), then a fresh blind set2 with its own pre-registration"}
{"ts": 1793819889, "iso": "2026-11-04T19:18:09Z", "event": "scored", "set": "set2", "verdict": "FAIL", "parts_passed": "3/8", "run": {"complete": true, "fixtures": "6/6", "errors": 0, "spent_usd": 2.569, "rows": 378, "detector": "af48ecc11 (v1.647.0)"}, "contamination": "clean: tool_use paths only in the fixture tempdir and the detector tree", "raw": "results-20261104T191040Z/score.json (sha256 85496ba1e47d2065), all parts pending adjudication", "adjudicated": "results-20261104T191521Z/score.json (sha256 e1eed64a4513877e); verdicts adj-verdicts.json (sha256 331f7434c084b7cc): independent Sonnet adjudicator, no truth access, 65/65 rows, coordinator spot-check 3/3 TPs hold", "parts": {"routes": {"R": "34/34", "P": "34/41", "P_lo": 0.69, "pass": true}, "outbound": {"R": "34/34", "P": "34/47", "P_lo": 0.58, "pass": false}, "rate_limit": {"R": "16/19", "P": "16/26", "P_lo": 0.43, "pass": false}, "csrf": {"R": "19/19", "P": "19/26", "P_lo": 0.54, "pass": false}, "cookie_flags": {"R": "12/12", "P": "12/14", "P_lo": 0.6, "pass": true}, "pii_log": {"R": "12/12", "P": "12/20", "P_lo": 0.39, "pass": false}, "pii_data": {"R": "14/14", "P": "14/16", "P_lo": 0.64, "pass": true}, "prompt_injection": {"R": "11/12", "P": "11/14", "P_lo": 0.52, "pass": false}}, "route_inventory": {"found": 120, "listed": 234, "basis": "route_inventory rows"}, "root_causes": "precision only: wrong cited line (route/helper instead of sink), wrong class (credential logged tagged pii-in-log; PII to vendor tagged pii-in-log), non-sink rows, missed mitigations (limiter applied, SameSite=Lax POST, cookie flags in config)", "note": "adjudicator rubric (unsure->fp, wrong class->fp) was written after set2 rows existed; set3 pre-registers it"}
Loading
Loading