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
1 change: 1 addition & 0 deletions .claude/skills/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Run `python3 <skill>/scripts/<name>` (`bash` for `.sh`). `name: purpose — argu
- context_pack.py: bounded context pack for a DIFF review. — [--base REF] [--repo DIR] [--intent…
- cost_limit_map.py: heuristic lead-finder for costly or unbounded HTTP endpoints… — DIR
- coverage_ledger.py: completeness check for a machine-report coverage map. — [--domains SPEC] <findings.json>
- csrf_cookie_map.py: heuristic lead-finder for cookie-session handlers with no CSRF… — DIR
- dependency_currency.py: how far behind is every dependency, and is it vulnerable. — [--root DIR] [--stdin] [--json]…
- derived_numbers.py: bind a doc number to the counter that derives it. — [--fix] [--selftest] [ROOT]
- design_drift.py: zero-token check that UI code still uses the project's design… — [--strict] [--json] [--tokens FILE]…
Expand Down
1 change: 1 addition & 0 deletions .claude/skills/deep-code-review/INDEX-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Generated by `scripts/skill_index.py` (do not hand-edit). The script half of `IN
| `scripts/context_pack.py` | bounded context pack for a DIFF review. | context_pack.py [--base REF] [--repo DIR] [--intent FILE\|-] [--cap N] [--max-bytes N] |
| `scripts/cost_limit_map.py` | heuristic lead-finder for costly or unbounded HTTP endpoints with no rate or quota limit evidence (… | python3 -I cost_limit_map.py DIR |
| `scripts/coverage_ledger.py` | completeness check for a machine-report coverage map. | coverage_ledger.py [--domains SPEC] <findings.json> |
| `scripts/csrf_cookie_map.py` | heuristic lead-finder for cookie-session handlers with no CSRF defence and session cookies set with… | python3 -I csrf_cookie_map.py DIR |
| `scripts/dependency_currency.py` | how far behind is every dependency, and is it vulnerable. | dependency_currency.py [--root DIR] [--stdin] [--json] [--budget SECS] [--today YYYY-MM-DD] |
| `scripts/derived_numbers.py` | bind a doc number to the counter that derives it. | python3 derived_numbers.py [--fix] [--selftest] [ROOT] Exit codes: 0 ok (or fixed); 1 drift or bad marker; 2 usage or s… |
| `scripts/design_drift.py` | zero-token check that UI code still uses the project's design tokens. | design_drift.py [--strict] [--json] [--tokens FILE] [--base REF] [PATH...] |
Expand Down
4 changes: 2 additions & 2 deletions .claude/skills/deep-code-review/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ Generated by `scripts/skill_index.py` (do not hand-edit; rerun it after changing
| `references/ux-writes.md` | the target or diff writes from the UI: an optimistic mutation whose failure path rolls back, a load… | 2949 |
| `references/web-fetch.md` | the target or diff fetches data for a view: dependent requests on the render-critical path, a share… | 5710 |
| `references/web-render.md` | the target or diff renders a list or grid of rows / tiles, adds or removes React.memo / useMemo / u… | 4731 |
| `references/whole-project-report.md` | writing a whole-project security audit report, or when scripts/report_contract_lint.py rejects one. | 846 |
| `references/whole-project-report.md` | writing a whole-project security audit report, or when scripts/report_contract_lint.py rejects one. | 1041 |

## Scripts

44 scripts. Read `INDEX-scripts.md` when you need a script (a trigger and CLI per script). `../INDEX.md`, `### deep-code-review`, has only each one-line purpose and arguments.
45 scripts. Read `INDEX-scripts.md` when you need a script (a trigger and CLI per script). `../INDEX.md`, `### deep-code-review`, has only each one-line purpose and arguments.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Needs a running system: deployed config, WAF, runtime authz, vault, infra outsid

A security audit (`security-review-mode.md`) has a `## Findings` section with one finding per top-level list item: `[<class>] <repo-relative path>:<line> <severity>: <text>`. The path is the vulnerable handler or line, never a gate, helper or config used as evidence; give exactly one `path:line`, and put evidence cites after `evidence:` in the text or in other sections. Never cite a bare file name. A chain finding cites its end-state line as the primary and the other links after `evidence:`. Indented continuation lines, prose, and subsections whose heading names an attack path or chain are not linted.

One finding per vulnerable site, never a group or a range: each state-changing cookie-session handler without a CSRF defence (`csrf`, anchored on the line that commits the change, not the signature), each session-cookie set call missing a flag (`cookie-flags`, including a cookie that sets HttpOnly but not Secure or SameSite), each unauthenticated handler (`missing-authn`). A GET that sets a cookie is not `csrf`. The per-standard Files cell and the primary `path:line` list vulnerable sites only: a gate, middleware, interceptor, filter, helper or token table you read as evidence goes after `evidence:`, and a route a verified global gate covers is not `missing-authn`. Each `csrf-cookie` row from `review_checks.sh --full` is a lead: verify it, then file it at its own line.

Fixed class vocabulary: `missing-authn`, `missing-authz`, `object-access`, `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.

Example: `- [pii-data] src/api/users.py:42 high: serves SSNs and dates of birth unmasked. evidence: src/models.py:10`
Expand Down
15 changes: 9 additions & 6 deletions .claude/skills/deep-code-review/scripts/attempt_limit_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ def declend(lines, ln, py):
return len(lines)


def units(root, texts):
def units(root, texts, innermost=False):
"""{file: [(line, end, methods, route)]} of every handler under root, sorted by line: the route_auth_map inventory (JS/TS, Python, Go, Spring, Django), where a Go registration, a Django
`path(route, view)` and a Next `export const GET = handler` re-export are followed to the function they name (the unit is that function's first line), and `end` is the last line of
the handler. texts is filled with the masked text of every file read (comments blanked, strings kept)."""
the handler. texts is filled with the masked text of every file read (comments blanked, strings kept). A Go registration `HandleFunc(p, wrap(h))` follows `wrap`'s definition unless innermost is set, which follows `h`."""
def T(rel):
if rel not in texts:
raw = read(root, rel)
Expand Down Expand Up @@ -225,11 +225,12 @@ def find(rx, near):
tail = re.search(r"""["']\s*,\s*(.*)""", line)
d = None
if rel.endswith(".go") and tail:
for n in re.findall(r"[\w.]+", tail[1]):
for n in (lambda ns: ns[::-1] if innermost else ns)(re.findall(r"[\w.]+", tail[1])):
d = find(r"^func\s+(?:\([^)]*\)\s*)?%s\s*\(" % re.escape(n.rpartition(".")[2]), rel)
if d: break
elif rel.endswith(".py") and re.match(r"\s*(?:re_)?path\(|\s*url\(", line) and tail:
v = re.match(r"[\w.]+", tail[1])
elif rel.endswith(".py") and re.search(r"(?:^|[\s\[,(])(?:re_)?path\(|(?:^|[\s\[,(])url\(", line) and tail:
lit = [x for x in re.finditer(r"""["']([^"']*)["']\s*,\s*""", line) if x[1].strip("/") == (route or "").strip("/")] # the tail after THIS route's string, not the line's first
v = re.match(r"[\w.]+", line[lit[0].end():] if lit else tail[1])
d = v and find(r"^[ \t]*(?:async\s+)?(?:def|class)\s+%s\b" % re.escape(v[0].replace(".as_view", "").rpartition(".")[2]), rel)
else:
im = re.match(r"\s*export\s+const\s+\w+\s*=\s*(\w+)\s*;?\s*$", line) # `export const POST = handler;`, handler imported by name
Expand All @@ -241,7 +242,9 @@ def find(rx, near):
j = l - 2 # the decorators and annotations above a handler (blank, comment and multi-line argument lines between them too) belong to it, not to the handler before
while j >= 0:
s = above[j].strip()
if s.startswith("@"): l = j + 1
if s.startswith("@"):
if s.count("(") == s.count(")") and "{" in re.sub(r"\([^()]*\)", "", re.sub(r"\([^()]*\)", "", s)): break # a one-line declaration (class, or handler with its body) is not a decorator of the next handler; an unclosed `({` opens a multi-line annotation argument
l = j + 1
elif s and not s.startswith(("#", "//")):
k = next((k for k in range(j - 1, max(j - 16, -1), -1) if above[k].lstrip().startswith("@") and "\n".join(above[k:j]).count("(") > "\n".join(above[k:j]).count(")")), None)
if k is None: break
Expand Down
Loading
Loading