Public: anyone can read this; the crew can change it.

The forge pill shows on an app whose CSP allows only its own scripts: the proxy serves it from the app's host #8215

Parked opened this
Closed without merging

The pill's script is now served from every app's own host, so an app with script-src 'self' loads it. I haven't looked at lab production, so the "dot bottom-right" check is not done; it needs this deployed first. The affected toolbar tests, tsc --noEmit and the new test pass.

Notes

stopped parked by the crew deploy 80efd68

opened this

The pill's script is now served from every app's own host, so an app with script-src 'self' loads it. I haven't looked at lab production, so the "dot bottom-right" check is not done; it needs this deployed first. The affected toolbar tests, tsc --noEmit and the new test pass.

  • Proxy (src/apps/proxy.ts): GET or HEAD on /__forge/toolbar-<hash>.js now answers the pill's bytes on any app host. It sends text/javascript and public, max-age=31536000, immutable, plus the security headers. The route comes before the access check, because the bytes are public and named by their hash.
  • Tag (src/apps/toolbar.ts): toolbarTag writes src="/__forge/toolbar-<hash>.js" and adds data-forge="<forge origin>", escaped like the other data attributes.
  • Pill script: every place that read the forge's origin from me.src now reads data-forge, falling back to me.src. That covers the home link, pull link, "what is this" link, the "Comment, tell, make it yours" link and the crew links, so they still point at the forge.
  • Tests:
    • The new test/apps-toolbar-same-origin.test.ts proxies an app that answers script-src 'self'. It checks the tag's src is same-origin, that data-forge carries the forge origin, and that the app host serves the exact bytes with the right headers.
    • I updated apps-toolbar, never-lost, toolbar-keyboard and apps-pill-where for the new src. In apps-pill-where one assertion on the source text was wrong after the rename, so I changed it.
    • I did not run the new test against the unchanged code.

Not done or not run:

  • I kept the old /assets/toolbar-….js route on the forge, so already-cached pages still work.
  • toolbar-keyboard skipped here because no chromium starts in this sandbox.
  • The repository has no scripts/gate.ts, so the gate step did not run.
  • I did not run the full suite; the forge's check does that on push.

To try it: open a preview or lab's production in a browser. The page source should show <script src="/__forge/toolbar-…" data-forge="https://forge.open-platform.sh" …>, and the dot should appear bottom-right.

Closes #8209

3 earlier comments
commented

The pill's script is now served from every app's own host, so an app with script-src 'self' loads it. I haven't looked at lab production, so the "dot bottom-right" check is not done; it needs this deployed first. The affected toolbar tests, tsc --noEmit and the new test pass.

  • Proxy (src/apps/proxy.ts): GET or HEAD on /__forge/toolbar-<hash>.js now answers the pill's bytes on any app host. It sends text/javascript and public, max-age=31536000, immutable, plus the security headers. The route comes before the access check, because the bytes are public and named by their hash.
  • Tag (src/apps/toolbar.ts): toolbarTag writes src="/__forge/toolbar-<hash>.js" and adds data-forge="<forge origin>", escaped like the other data attributes.
  • Pill script: every place that read the forge's origin from me.src now reads data-forge, falling back to me.src. That covers the home link, pull link, "what is this" link, the "Comment, tell, make it yours" link and the crew links, so they still point at the forge.
  • Tests:
    • The new test/apps-toolbar-same-origin.test.ts proxies an app that answers script-src 'self'. It checks the tag's src is same-origin, that data-forge carries the forge origin, and that the app host serves the exact bytes with the right headers.
    • I updated apps-toolbar, never-lost, toolbar-keyboard and apps-pill-where for the new src. In apps-pill-where one assertion on the source text was wrong after the rename, so I changed it.
    • I did not run the new test against the unchanged code.

Not done or not run:

  • I kept the old /assets/toolbar-….js route on the forge, so already-cached pages still work.
  • toolbar-keyboard skipped here because no chromium starts in this sandbox.
  • The repository has no scripts/gate.ts, so the gate step did not run.
  • I did not run the full suite; the forge's check does that on push.

To try it: open a preview or lab's production in a browser. The page source should show <script src="/__forge/toolbar-…" data-forge="https://forge.open-platform.sh" …>, and the dot should appear bottom-right.

commented

The forge's check on this pull failed because shard 8 was killed after 39 s while running test/user-lists-page.test.ts. I think that was machine load, not my change, but I haven't confirmed it.

  • The failing test: it has nothing to do with the pill or the toolbar, and I didn't touch it. It passes here in 1.3 s on its own. All 58 shards reported 0 failed tests except the killed one.
  • My change: the toolbar, proxy and pill tests pass here (48 pass, 4 skipped, 0 fail), and tsc --noEmit is clean.
  • What I did: I changed no code. I pushed an empty commit (83457f30) so the forge re-runs the check. If shard 8 is killed again, that's a real problem and needs another look.

What the pull does: the pill's script is now served from each app's own host. An app whose Content-Security-Policy allows only its own scripts therefore still shows the forge pill. The change is in src/apps/proxy.ts and src/apps/toolbar.ts, with a new test, test/apps-toolbar-same-origin.test.ts, and updated expectations in four existing toolbar tests.

To try it: open the preview at https://lab--8215--forge-trevato-apps.open-platform.sh, or any app that sends a self-only script CSP. The pill should appear.

What I left out: no change to how the pill looks or behaves, and nothing outside the proxy and toolbar modules.

commented

The six failing </body tests were my doing, and they pass now. test/toolbar-body-close.test.ts came in with main and looked for the pill's tag at src="http://f.test/. The tag now carries the app's own address (/__forge/…), so that prefix was out of date. The tag still lands before the last </body, in any case, or at the end of the page, so only the test's address was wrong. I changed that one line.

I merged origin/main to pick up the test, then pushed 80efd680. Locally the body-close, waves, toolbar and proxy-timing tests pass (51 pass, 0 fail) and tsc --noEmit is clean. The forge's full check hasn't run on this push yet.

test/waves.test.ts showed up in the log as failing "only beside others" (its shard-mate was the body-close test). It passes here, and I didn't change it.

Pull description: the pill's script is now served from each app's own host (/__forge/toolbar-<hash>.js), with the forge's address passed in a data-forge attribute. An app whose Content-Security-Policy allows only its own scripts therefore still shows the pill. The change is in src/apps/proxy.ts and src/apps/toolbar.ts. test/apps-toolbar-same-origin.test.ts is new. Four existing toolbar tests and the body-close test were updated for the new address. I left the pill's look and behaviour alone. To try it, open the preview at https://lab--8215--forge-trevato-apps.open-platform.sh, or any app that sends a self-only script CSP; the pill should appear.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs