Repository navigation
test(page-csp): gate external iframe origins against frame-src - #311
Conversation
The CSP gate already keeps every external <img> origin covered by img-src, but #307 added the site's first third-party <iframe> and nothing shared pinned its origin to frame-src: a frame whose origin is not allowed is silently replaced by an empty box, and a frame-src origin no page uses widens the allow-list for nothing. externalFrameOrigins() mirrors externalImageOrigins(); problemsOf() resolves frame-src -> child-src -> default-src as browsers do, accepts https: as the img-src rule does, and reports an explicit frame-src origin that no <iframe> on the page points at. Each branch has a fixture self-test so coverage-floor stays at zero for the helper. Fixes #310 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Read scripts/page-csp.mjs at 1524cb4 alongside the existing img-src rule and parseCsp. Looks correct to me.
externalFrameOrigins(page-csp.mjs:53-60) mirrorsexternalImageOriginsexactly: sameattrs()parser, same^https?://filter, samenew URL().originnormalisation, sosrcdoc/relative/about:frames are skipped and host case is folded.- The
frame-src → child-src → default-srcfallback (page-csp.mjs:134) is the CSP3 resolution order;index.htmlcarriesframe-src https://www.youtube-nocookie.comand one<iframe>, so the live gate passes unchanged — confirmed by runningnode --test scripts/*.test.mjsat head (812 pass, 0 fail). - The four new fixture tests fail against
main'spage-csp.mjs(missing export), so they do pin the behaviour.
One non-blocking note: like the img-src rule, the stale-origin check compares whole tokens, so a path-qualified source expression (e.g. frame-src https://host/embed/) would be reported as unused. Nothing on the site does that today and it is consistent with the existing rule, so no change needed.
Not approving (human signature); no overlap with #309 after reading both file sets.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Looks correct to me; one low-severity note on the new stale-origin rule, not a blocker. Verified against the tree at Low — path-form (reproduced with |
Summary
Extends the CSP gate so
<iframe>origins are checked againstframe-srcthe way<img>origins are already checked againstimg-src.Why: #307 added the site's first third-party frame plus
frame-src https://www.youtube-nocookie.com, but nothing shared tied the two together — only a page-specific regex infeatured-video.test.mjs. A frame added elsewhere without aframe-srcentry would pass the suite and render as an empty box; aframe-srcorigin left behind after a frame is removed would widen the allow-list with no signal.problemsOf()now resolvesframe-src→child-src→default-src(the browser's order), acceptshttps:exactly as theimg-srcrule does, and reports an explicitframe-srcorigin no<iframe>on the page uses (the analogue of the stale-hash rule). Every new branch has a fixture self-test, socoverage-floor.test.mjsstays at zero dead ranges forpage-csp.mjs;index.htmlpasses unchanged.Fixes #310
Does not overlap #309 (that PR edits the iframe's
sandboxattribute,featured-video.test.mjsand the README's description of that gate; this one touchespage-csp.mjs,page-csp.test.mjsand the README paragraph on the CSP gate).Screenshots
No page change.
Checks run locally
node --test scripts/*.test.mjs(812 pass;page-csp.test.mjsfails onmainwith this test file)scripts/check-links.sh --external-warn(no link changes)scripts/check-links.test.shscripts/check-redirects.test.shscripts/check-redirects.shChecklist
<script>edited (no CSP hash update needed)git commit -s)Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88