Skip to content

chore(claude): widen the security-review trigger paths - #139

Merged
Ardnived merged 3 commits into
mainfrom
chore/security-review-paths
Aug 11, 2026
Merged

Ardnived merged 3 commits into
mainfrom
chore/security-review-paths

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • /finalize-pr's security-review path grep did not match docs(claude): refresh stale internal docs and small hygiene batch #100's branch — the one whose entire point was hardening the Link atom's href guard. A security-reviewer pass ran anyway, on judgement, and that is the only reason the protocol-relative-URL gap (//evil.com walking through href.startsWith('/')) was caught before merge. A gate that depends on somebody overriding it is not a gate.
  • Widens the list to the client-side surfaces that have since become security-relevant, and writes down why each is there so the next person prunes it on reasons rather than taste.
  • Re-syncs one pre-existing drifted line in .claude/docs/workflow-parity.md so the three-repo byte-identical invariant can actually be restored.

Changes

  • .claude/skills/finalize-pr/SKILL.md — the path regex, its comment, the prose above it, and a new note on how to widen it (deliberately, never maximally) plus what deliberately stays out.
  • .claude/docs/workflow-parity.md — the SahajAtlasWeb cell of the "Security-review trigger paths" row (80), and the "Lean gate contents" row (79) re-synced from SahajCloud.

What was added, and what earns each its place

Added Why
src/lib/shape/path Home of safePath, the repo's single definition of "same-origin route". src/lib/shape/lexical was covered and the URL guard beside it was not — backwards.
src/lib/shape/href #114/#136 lifted isSafeHref here; it is the last gate before any JSX <a href>. A javascript: string past it runs in the host page's realm.
src/components/atoms/Link/ The atom that turns a CMS-driven string into an anchor. Named in .claude/reports/100-refresh-internal-docs.md §5 as the path worth adding.
src/lib/shape/hash .claude/agents/security-reviewer.md names it beside Widget.tsx as the host trust boundary — claimFragment(mountRoute(…)), "an untrusted input picking a branch, so audit both" (#92). Widget.tsx was listed; this was not.
src/styles/, src/lib/scope, scripts/[^/]*css, postcss.config.js The stylesheet is injected into the host document, so an unscoped selector restyles a site we don't control. #91 and #104 both found real leaks. These are what enforce the isolation — lib/scope.ts names the scope the PostCSS pass rewrites every selector under, and vaul.css is the other half of the sheet.
src/App.tsx Provider/boundary root: RootBoundary, the report-modal host mounted outside it, the client bootstrap.
src/config/privacy #95's host-declared opt-outs. A change here can silently re-enable Fathom, an IP lookup, or Sentry in somebody else's page — the host, not us, is the controller answering for it.
src/lib/report #108 wired Sentry through this one seam, on a private BrowserClient/Scope rather than Sentry.init (which would hook the host page's global error events). It decides what leaves the visitor's browser.
pnpm-lock.yaml, patches/ The supply-chain pair: the transitive bump that never touches package.json, and arbitrary code applied to a dependency — patches/[email protected] exists precisely because vaul leaked a bare @keyframes into host pages.

The module entries are unanchored on purpose (src/lib/shape/path, not path\.ts), so a spec travels with its module. Several of these guards are enforced by an assertion rather than by a reader — href.test.ts pins the JSX-anchor inventory to exactly three components, path.test.ts pins //evil.com and the tab/LF/CR forms — and deleting one of those assertions is the diff most worth seeing. The pre-existing entries (src/config/api/, src/types/event, src/lib/shape/lexical, EventDetails/) already behaved this way.

Deliberately, not maximally

A trigger that fires on everything is worth no more than one that never fires, because it stops being read. Measured over the last 84 commits on main: the old list fires 51 times, this one 55. Newly caught:

Two candidates were considered and left out: src/config/i18n-options.ts (its one privacy property, caches: [], is asserted at i18n-options.test.ts:158) and tailwind.config.js (whatever it emits, scripts/assert-css-scoped.mjs fails the build if it escapes the scope). A red gate is faster and surer than a review — the note in SKILL.md now says to prefer adding the assertion over adding the path.

Evidence (run against the regex extracted from the committed file, not a copy)

Must fire — git diff --name-only <c>~1 <c> | grep -E "$RX":

e1b4a3a  docs(claude): refresh stale internal docs... (#111)   → 2 files   [old regex: NO MATCH]
e730a25  fix(ui): scope widget css... (#113)                   → 13 files  [old: 2, incidental]
31e61bf  refactor(ui): gate every anchor href... (#136)        → 3 files   [old: NO MATCH]

#113 did fire before — but only via package.json and src/Widget.tsx. A pure CSS-scoping change would not have.

Must not fire (all six produce no match):

c608019 Upload all locales                    13be0db Fix weekday substitutions
2e9ecc2 Fix hosted_from translation           3dcc37a Update Accent
ca225b0 refactor(stories): flatten story titles to the bare tier
135f26e fix(atoms): use plain triggers in Dropdown story so demos open

Verification

  • Lint: ✓ No errors (pnpm lint)
  • Types: ✓ Clean (pnpm typecheck)
  • Tests: ✓ Unit lane green — 960 tests / 81 files (pnpm test:run)
  • Build: N/A — nothing under src/ changed; skill + doc text only
  • Security review: correctly skipped — this branch touches only .claude/**, matching neither the widened path list nor the content-based HTML-sink grep
  • /code-review: one dispatched pass. Three should-fix findings, all accepted and fixed in fa10594 (they cost one extra firing across 84 commits, measured before accepting). Nothing dismissed.

Three-repo parity

.claude/docs/workflow-parity.md is kept byte-identical across SahajAtlasWeb, SahajCloud and WeMeditateWeb. Checking that criterion turned up pre-existing drift predating this ticket: SahajCloud's #607 (3be34cc0, 2026-07-31) corrected its own cell of the Lean gate contents row and never ported the edit, so all three have disagreed on line 79 since. Read from each repo's origin/main, before this branch:

  • SahajAtlasWeb ≡ WeMeditateWeb — identical (82 lines).
  • SahajCloud — differs on line 79 only.

This PR adopts SahajCloud's line-79 text (strictly the accurate one), which leaves one patch per sibling and lets all three converge.

Companion PRs — both open and already carrying the final text:

All three PR branches now hold a byte-identical copy of the file (md5 3fd59b4bc8674854fb619f7aa3773ae7, verified via the contents API). All three must merge for the invariant to hold.

Notes for reviewer

  • The regex stays a single-line grep -E alternation with dots escaped, as the existing entries do; ERE validity confirmed under BSD grep -E and Python re.
  • scripts/[^/]*css is a pattern rather than two literal filenames so the CSS-scoping family survives a rename; repo-wide it matches only the three postcss-scope-widget.* / assert-css-scoped.mjs files.
  • Repo-wide the full list matches 52 of 469 tracked files.
  • The line-79 re-sync is its own commit (679fad7) so it can be reviewed apart from the widening.

Closes #117

🤖 Generated with Claude Code

Ardnived and others added 2 commits August 7, 2026 21:12
The path grep in /finalize-pr did not match #100's branch — the one whose
entire point was hardening the Link atom's href guard. A security review ran
anyway, on judgement, and that is the only reason the protocol-relative-URL
gap (//evil.com walking through href.startsWith('/')) was caught before merge.
A gate that depends on someone overriding it is not a gate.

Adds the client-side surfaces that have since become security-relevant:
the same-origin/scheme guard (shape/path.ts, shape/href.ts, atoms/Link/),
the host-page CSS isolation that #91/#104 built (styles/globals.css,
lib/scope.ts, the PostCSS scoping script + config), the app root, the
privacy opt-outs and the reporting seam Sentry hangs off, and the lockfile
for a transitive bump that never touches package.json.

Deliberately, not maximally: over the last 82 commits on main the widened
list fires 54 times against the old 51, and two of those three additions are
#111 and #136 — the href-guard branches this exists to catch. Verified to
still not fire on a locale-only or stories-only diff.

Closes #117

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Pre-existing drift, found while checking this ticket's byte-identical
criterion: SahajCloud's #607 (3be34cc0, 2026-07-31) corrected its own cell
of the "Lean gate contents" row to `lint + typecheck + typecheck:tests +
test:unit` and did not port that edit to the other two copies, so all three
have disagreed on line 79 since. Adopting SahajCloud's text here — it is
strictly the accurate one — leaves ONE patch to carry to each sibling and
lets all three converge.

Refs #117

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Ardnived added a commit to sydevs/SahajCloud that referenced this pull request Aug 8, 2026
Port of the byte-identical deltas-table row from
sydevs/SahajAtlasWeb#139. Only the SahajAtlasWeb cell of the
"Security-review trigger paths" row changes; SahajCloud's own cell
and every other line are untouched.

The spec file is kept byte-identical across the three repos, so this
edit has to land here too or /sync-workflow reports drift.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: fa10594
Status: ✅  Deploy successful!
Preview URL: https://c45b046d.sahajatlas.pages.dev
Branch Preview URL: https://chore-security-review-paths.sahajatlas.pages.dev

View logs

Ardnived added a commit to sydevs/WeMeditateWeb that referenced this pull request Aug 8, 2026
Two rows of the deltas table, both ported from other repos; nothing
about WeMeditateWeb's own workflow changes.

- Security-review trigger paths: the SahajAtlasWeb cell, widened in
  sydevs/SahajAtlasWeb#139.
- Lean gate contents: the SahajCloud cell, corrected by that repo's
  #607 (3be34cc0) and never ported, so all three copies have
  disagreed on that line since 2026-07-31.

The spec is kept byte-identical across the three repos; with this
and sydevs/SahajCloud#622 all three match again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three findings, all accepted. Cost: ONE extra firing across the last 84
commits (54 → 55), measured before accepting.

- Unanchor the five module entries so a SPEC travels with its module.
  The `\.ts` suffixes excluded href.test.ts, path.test.ts, privacy.test.ts
  and the two report specs — so deleting an assertion triggered nothing,
  which hollowed out the very paragraph telling readers to prefer an
  assertion over a path. The pre-existing entries (src/config/api/,
  src/types/event, shape/lexical, EventDetails/) already behaved this way;
  the new ones were the inconsistent ones.
- Add src/lib/shape/hash — .claude/agents/security-reviewer.md names it
  beside Widget.tsx as the host trust boundary, "an untrusted input picking
  a branch, so audit both" (#92). Widget.tsx was listed and hash.ts was not:
  the same asymmetry as lexical-vs-path that this ticket exists to fix.
- Broaden to src/styles/ (vaul.css is the other half of the injected sheet)
  and add patches/ — a patch is arbitrary code applied to a dependency, and
  patches/[email protected] exists precisely because vaul leaked a bare
  @Keyframes into host pages.

Also rewrites the "what does not belong here" paragraph, which cited
href.test.ts as an example of an excluded surface while href.ts sat in the
list two lines above. It now names the genuinely-absent i18n-options.ts and
explains the unanchoring rule instead.

The deltas-table cell follows the list, so the sibling ports were refreshed.

Refs #117

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Ardnived added a commit to sydevs/SahajCloud that referenced this pull request Aug 8, 2026
Follows the code-review pass on sydevs/SahajAtlasWeb#139, which widened
that repo's list further (host-fragment routing, the rest of the injected
stylesheet, dependency patches) and unanchored the module entries so a
spec travels with its module. Only the SahajAtlasWeb cell moves.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Ardnived added a commit to sydevs/WeMeditateWeb that referenced this pull request Aug 8, 2026
Follows the code-review pass on sydevs/SahajAtlasWeb#139, which widened
that repo's list further (host-fragment routing, the rest of the injected
stylesheet, dependency patches) and unanchored the module entries so a
spec travels with its module. Only the SahajAtlasWeb cell moves.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Ardnived added a commit to sydevs/SahajCloud that referenced this pull request Aug 11, 2026
* docs(claude): widen SahajAtlasWeb's security-review trigger paths

Port of the byte-identical deltas-table row from
sydevs/SahajAtlasWeb#139. Only the SahajAtlasWeb cell of the
"Security-review trigger paths" row changes; SahajCloud's own cell
and every other line are untouched.

The spec file is kept byte-identical across the three repos, so this
edit has to land here too or /sync-workflow reports drift.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(claude): refresh the ported trigger-paths cell

Follows the code-review pass on sydevs/SahajAtlasWeb#139, which widened
that repo's list further (host-fragment routing, the rest of the injected
stylesheet, dependency patches) and unanchored the module entries so a
spec travels with its module. Only the SahajAtlasWeb cell moves.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit 03f9b61 into main Aug 11, 2026
5 checks passed
@Ardnived
Ardnived deleted the chore/security-review-paths branch August 11, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(claude): widen the security-review trigger paths

1 participant