fix(diffanalysis): anchor sensitive-path keywords at both ends #88

Merged
rcsheets merged 1 commit from fix/sensitive-path-anchoring into main 2026-07-28 05:10:28 +00:00
Owner

| binds looser than concatenation, so (^|/)auth|oauth|... parsed as ((^|/)auth)|(oauth)|... — only the first branch was anchored to a path segment, and every other branch was a bare substring match anywhere in the path.

Grouping the alternation fixes the leading end. That alone left the prefix case: with the boundary satisfied, token still matched pkg/tokenizer/ and chart matched dashboard/charts.go. A trailing ([^a-zA-Z]|$) closes it.

Observed before the fix:

Path Tag emitted
internal/design/layout.go Touches security
internal/assignment/assign.go Touches security
web/static/signup.css Touches security
internal/dashboard/charts.go Touches Helm chart
pkg/tokenizer/lex.go Touches authentication/authorization
cmd/immigration/main.go Touches database migration

These reach the model as flat assertions (- Touches **security**: ...), so a false one aims the review at a threat model the diff has nothing to do with.

The trailing boundary costs the ability to match derived forms implicitly, so they're spelled out (migration/migrations, encrypt/encrypted/encryption) — nothing distinguishes "tokens" from "tokenizer" by shape alone. Bare sign is dropped rather than enumerated, since signup/signal/assign swamped the code-signing sense; signing and signature carry it now. Helm keys off helm/, charts/, or Chart.yaml specifically.

Tags are also deduped per file, since Helm now has three spellings and a path matching two of them would otherwise be listed twice under the same tag.

Tests cover both directions: the false positives above stay untagged, and real auth/crypto/migration/Helm paths still match at root and nested.

🤖 Generated with Claude Code

`|` binds looser than concatenation, so `(^|/)auth|oauth|...` parsed as `((^|/)auth)|(oauth)|...` — only the first branch was anchored to a path segment, and every other branch was a bare substring match anywhere in the path. Grouping the alternation fixes the leading end. That alone left the prefix case: with the boundary satisfied, `token` still matched `pkg/tokenizer/` and `chart` matched `dashboard/charts.go`. A trailing `([^a-zA-Z]|$)` closes it. Observed before the fix: | Path | Tag emitted | |---|---| | `internal/design/layout.go` | Touches **security** | | `internal/assignment/assign.go` | Touches **security** | | `web/static/signup.css` | Touches **security** | | `internal/dashboard/charts.go` | Touches **Helm chart** | | `pkg/tokenizer/lex.go` | Touches **authentication/authorization** | | `cmd/immigration/main.go` | Touches **database migration** | These reach the model as flat assertions (`- Touches **security**: ...`), so a false one aims the review at a threat model the diff has nothing to do with. The trailing boundary costs the ability to match derived forms implicitly, so they're spelled out (migration/migrations, encrypt/encrypted/encryption) — nothing distinguishes "tokens" from "tokenizer" by shape alone. Bare `sign` is dropped rather than enumerated, since signup/signal/assign swamped the code-signing sense; `signing` and `signature` carry it now. Helm keys off `helm/`, `charts/`, or `Chart.yaml` specifically. Tags are also deduped per file, since Helm now has three spellings and a path matching two of them would otherwise be listed twice under the same tag. Tests cover both directions: the false positives above stay untagged, and real auth/crypto/migration/Helm paths still match at root and nested. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(diffanalysis): anchor sensitive-path keywords at both ends
All checks were successful
ci / check (pull_request) Successful in 43s
d05342cde1
`|` binds looser than concatenation, so `(^|/)auth|oauth|...` parsed as
`((^|/)auth)|(oauth)|...` — only the first branch was anchored to a path
segment and the rest were bare substring matches. internal/design/ was
tagged "security", cmd/immigration/ "database migration". Grouping the
alternation fixes the leading end.

That alone left the prefix case: with the boundary satisfied, "token"
still matched pkg/tokenizer/ and "chart" matched dashboard/charts.go. A
trailing ([^a-zA-Z]|$) closes it, at the cost of spelling out derived
forms, since nothing distinguishes "tokens" from "tokenizer" by shape.
Bare "sign" is dropped rather than enumerated — signup/signal/assign
swamped the code-signing sense — with "signing" and "signature" left to
carry it. Helm now keys off helm/, charts/, or Chart.yaml specifically.

These tags reach the model as flat assertions ("Touches **security**"),
so a false one aims the review at a threat model the diff has nothing to
do with. Tags are also deduped per file, since Helm now has three
spellings and a path matching two of them would be listed twice.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator

Automated review by pr-reviewer v0.41.3 | Safety Check | Claude Sonnet 5 | tracking id r-6826be-6565ab
This is an AI-generated review and may contain mistakes.

Status: Completed


⚠️ The primary review (Mistral Small) failed. The review below is from Claude Sonnet 5, which reviewed the same diff.

Verdict: LGTM — The PR is a targeted, well-tested regex bug fix with no security or stability concerns.

The change is a well-scoped regex fix: grouping the alternation and adding a trailing boundary correctly addresses the described false-positive bug, and the reasoning in the comments matches the code. Tests cover both the previously-false-positive paths and real matches at root/nested paths, plus dedup behavior.

Quick sanity checks on the regex logic:

  • (?i)(^|/)(migrate|migrates|migration|migrations)([^a-zA-Z]|$) etc. — grouping looks correct, trailing boundary excludes alphabetic continuations, which is the intent.
  • Helm split into three separate patterns (helm, charts/, Chart.yaml) — reasonable, avoids over-matching chart as prefix.
  • Dedup via seenTags map keyed by tag correctly prevents duplicate tags per file from multiple patterns.

No secrets, no unrelated changes, no breaking API changes — this only affects internal tagging heuristics used for review commentary, not build/deploy logic. Nothing alarming.

*Automated review by [pr-reviewer](https://git.brooktrails.org/brooktrails/pr-reviewer) v0.41.3 | Safety Check | Claude Sonnet 5 | tracking id `r-6826be-6565ab`* *This is an AI-generated review and may contain mistakes.* **Status:** ✅ Completed --- > ⚠️ The primary review (**Mistral Small**) failed. The review below is from **Claude Sonnet 5**, which reviewed the same diff. **✅ Verdict: LGTM** — The PR is a targeted, well-tested regex bug fix with no security or stability concerns. The change is a well-scoped regex fix: grouping the alternation and adding a trailing boundary correctly addresses the described false-positive bug, and the reasoning in the comments matches the code. Tests cover both the previously-false-positive paths and real matches at root/nested paths, plus dedup behavior. Quick sanity checks on the regex logic: - `(?i)(^|/)(migrate|migrates|migration|migrations)([^a-zA-Z]|$)` etc. — grouping looks correct, trailing boundary excludes alphabetic continuations, which is the intent. - Helm split into three separate patterns (`helm`, `charts/`, `Chart.yaml`) — reasonable, avoids over-matching `chart` as prefix. - Dedup via `seenTags` map keyed by tag correctly prevents duplicate tags per file from multiple patterns. No secrets, no unrelated changes, no breaking API changes — this only affects internal tagging heuristics used for review commentary, not build/deploy logic. Nothing alarming.
rcsheets force-pushed fix/sensitive-path-anchoring from d05342cde1
All checks were successful
ci / check (pull_request) Successful in 43s
to a986b589db
All checks were successful
ci / check (pull_request) Successful in 41s
2026-07-28 05:06:09 +00:00
Compare
Collaborator

Automated review by pr-reviewer v0.41.5 | Safety Check | Claude Sonnet 5 | tracking id r-6838c3-c7d95c
This is an AI-generated review and may contain mistakes.

Status: Completed


⚠️ The primary review (Mistral Small) failed. The review below is from Claude Sonnet 5, which reviewed the same diff.

Verdict: LGTM — The PR is a targeted, well-tested regex fix for a real precedence/prefix-matching bug in sensitive-path tagging, with no signs of secrets, breaking changes, or other issues.

This is a well-scoped regex fix with clear before/after reasoning and tests covering both the false-positive and true-positive directions. I checked the regex logic:

  • Grouping the alternation (auth|authn|...) inside (^|/)(...)([^a-zA-Z]|$) correctly fixes the precedence bug described.
  • Trailing boundary ([^a-zA-Z]|$) correctly prevents prefix matches like tokenizer matching token.
  • Dedup via seenTags map is straightforward and correctly prevents duplicate tags per file.
  • Helm chart patterns (helm/, charts/, Chart.yaml) are more precise and match the stated intent.
  • Tests directly encode the described false positives (should not match) and true positives (should match), which is good verification.

No secrets, no committed binaries, no breaking API changes — this only affects internal tagging/heuristics used for review context, not core diff logic. I don't see any correctness issues with the regex changes as described.

*Automated review by [pr-reviewer](https://git.brooktrails.org/brooktrails/pr-reviewer) v0.41.5 | Safety Check | Claude Sonnet 5 | tracking id `r-6838c3-c7d95c`* *This is an AI-generated review and may contain mistakes.* **Status:** ✅ Completed --- > ⚠️ The primary review (**Mistral Small**) failed. The review below is from **Claude Sonnet 5**, which reviewed the same diff. **✅ Verdict: LGTM** — The PR is a targeted, well-tested regex fix for a real precedence/prefix-matching bug in sensitive-path tagging, with no signs of secrets, breaking changes, or other issues. This is a well-scoped regex fix with clear before/after reasoning and tests covering both the false-positive and true-positive directions. I checked the regex logic: - Grouping the alternation `(auth|authn|...)` inside `(^|/)(...)([^a-zA-Z]|$)` correctly fixes the precedence bug described. - Trailing boundary `([^a-zA-Z]|$)` correctly prevents prefix matches like `tokenizer` matching `token`. - Dedup via `seenTags` map is straightforward and correctly prevents duplicate tags per file. - Helm chart patterns (`helm/`, `charts/`, `Chart.yaml`) are more precise and match the stated intent. - Tests directly encode the described false positives (should not match) and true positives (should match), which is good verification. No secrets, no committed binaries, no breaking API changes — this only affects internal tagging/heuristics used for review context, not core diff logic. I don't see any correctness issues with the regex changes as described.
rcsheets deleted branch fix/sensitive-path-anchoring 2026-07-28 05:10:29 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
brooktrails/pr-reviewer!88
No description provided.