Skip to content

fix(artifacts): allow same-site navigations, fit Mermaid, inset the focused view - #5543

Open
shepherdjerred wants to merge 1 commit into
mainfrom
artifacts-acceptance-fixes-2
Open

shepherdjerred wants to merge 1 commit into
mainfrom
artifacts-acceptance-fixes-2

Conversation

@shepherdjerred

@shepherdjerred shepherdjerred commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Why

Live acceptance of the artifacts service found four problems: links into artifacts from Hub, Tracker and Flags returned 403; Mermaid rendered tiny; the floating pill covered the top of the focused viewer (cast, video controls); and a hostile framed form turned the viewer frame into a Chrome error page, which needed explaining and a regression test.

What

  • Navigation guard (src/domain/csrf.ts): GET/HEAD top-level document navigations (Sec-Fetch-Mode: navigate, Dest: document) are allowed when Sec-Fetch-Site is same-site, as they already were for none. cross-site navigations (a sandboxed artifact), frame navigations, every non-GET that is not same-origin, and same-site/cross-site subresource or API requests stay 403.
  • Framed form POST, root cause: not missing headers. form-action 'none' is enforced and reports a violation; the frame's error page is Chrome refusing the navigation under the app page's frame-src <content origin> (the frame cannot navigate to the app origin), and no request is sent. Proven with a two-host e2e and an app-side request log (see Demo). The CSRF guard remains the second line. The e2e content host now serves the real contentHeaders instead of a drifted copy.
  • Focused view: starts below the pill (--ar-inset-top, published by the pill from its measured bottom edge plus 8 px). The canvas does not use it.
  • Mermaid viewer: fits the frame (up to 3x natural, down as needed, held to the frame height unless already at natural size). The e2e content host now serves the real viewer page and bundle.
  • Cleanup (live): board acceptance-scratch archived via boards.archive; acceptance-live untouched.

Demo

Focused views, before and after

View Before After
Mermaid (tiny, then fitted)
Cast (pill clipped the top of the player)
Video (pill covered the top of the clip)
Canvas (unchanged; only the Flow preview now fills its frame)

Navigation guard matrix (generated from checkCsrf)

Request Method Sec-Fetch-Site Result
document navigation GET none allow
document navigation GET same-origin allow
document navigation GET same-site allow
document navigation GET cross-site 403 cross-site
document navigation HEAD none allow
document navigation HEAD same-origin allow
document navigation HEAD same-site allow
document navigation HEAD cross-site 403 cross-site
form POST navigation POST none 403 navigation-only
form POST navigation POST same-origin allow
form POST navigation POST same-site 403 cross-site
form POST navigation POST cross-site 403 cross-site
iframe navigation GET none 403 navigation-only
iframe navigation GET same-origin allow
iframe navigation GET same-site 403 cross-site
iframe navigation GET cross-site 403 cross-site
fetch / API GET none 403 navigation-only
fetch / API GET same-origin allow
fetch / API GET same-site 403 cross-site
fetch / API GET cross-site 403 cross-site
image / no-cors GET none 403 navigation-only
image / no-cors GET same-origin allow
image / no-cors GET same-site 403 cross-site
image / no-cors GET cross-site 403 cross-site
fetch POST POST none 403 navigation-only
fetch POST POST same-origin allow
fetch POST POST same-site 403 cross-site
fetch POST POST cross-site 403 cross-site

Framed hostile form: where the request dies

Two-host e2e (e2e/hostile-frame.spec.ts), a form with no target posting at the app origin from inside the viewer frame. The app listener logs every request before any handler runs.

form-action app frame-src Frame ends as Request reached the app
'none' (shipped) content origin only (shipped) Chrome error page (chrome-error://), console reports both violations no
'none' widened to the app stays on the artifact no
* content origin only Chrome error page no (the app page's frame-src blocks it)
* widened to the app the app's response yes: POST /api/_e2e/probe, Sec-Fetch-Site: cross-site, Dest: iframe (the CSRF guard answers 403 in production)

Each directive is independently sufficient to stop the request; both are shipped. The test fails when both are loosened.

Verification

  • bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts: green (454 unit tests; conformance allowlist unchanged).
  • bun run test:e2e in packages/artifacts (desktop, mobile, webkit): 239 passed, including the new hostile-frame and focused-inset specs and the updated shell spec (the focused viewer no longer starts at y=0).
  • Root: //#knip //#jscpd //#check-flag-usage //#check-directory-file-counts //#quality-ratchet: green. bunx lefthook run pre-commit: green.
  • Extended tier: no extended step in @shepherdjerred/artifacts is affected (no PostgreSQL or schema change).
  • Not verified here: live behaviour after deploy (same-site link from Hub returning 200; Mermaid on the live content host). Source and local checks only until CI, publish and ArgoCD complete.

🤖 Generated with Claude Code

https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

@shepherdjerred

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@greptile-apps

greptile-apps Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

…ocused view

Why
Live acceptance of the artifacts service found that a link from Hub, Tracker or
Flags got 403 (same-site GET navigations were rejected), Mermaid rendered tiny,
and the floating pill covered the top of the focused viewer (the cast and the
video controls). A framed hostile form also turned the viewer frame into a
Chrome error page; that needed an explanation and a test.

What
- csrf: a GET/HEAD top-level document navigation (Sec-Fetch-Mode navigate,
  Dest document) is allowed when Sec-Fetch-Site is same-site, as it already was
  for none. cross-site navigations, frame navigations, every non-GET and
  same-site or cross-site subresource requests are still refused.
- Framed form POST: not a missing header. form-action 'none' is enforced and
  reported; the frame's error page is Chrome refusing the navigation under the
  app page's frame-src, and no request reaches the app. The e2e content host now
  serves the real contentHeaders, the e2e app listener logs requests, and a
  hostile-fixture spec asserts nothing reaches the app (POST, GET, popup).
- The focused viewer starts below the pill (--ar-inset-top, published by the
  pill from its own measured bottom edge). The Mermaid viewer fits the frame
  (scale up to 3x natural, down as needed, held to the frame height unless it is
  already at natural size); the e2e content host serves the real viewer.

Verification
bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts
(454 unit tests, conformance allowlist unchanged); bun run test:e2e (desktop,
mobile, webkit: 239 passed); root //#knip //#jscpd //#check-flag-usage
//#check-directory-file-counts //#quality-ratchet; lefthook pre-commit. Not run:
live deployment checks, PostgreSQL extended tier (no change to it).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
@shepherdjerred
shepherdjerred force-pushed the artifacts-acceptance-fixes-2 branch from 08f5c8d to 25c169c Compare December 3, 2026 04:46
@shepherdjerred
shepherdjerred marked this pull request as ready for review December 3, 2026 04:46
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@shepherdjerred

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Automated re-review request for 25c169c from the CI review gate.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shepherdjerred

Copy link
Copy Markdown
Owner Author

@codex review

Automated re-review request for 25c169c from the CI review gate.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T04:49:46.984497Z 25c169c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 25c169c4fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

1 participant