Add iframe fetch proxy allowlist for ProcessGit viewer#81
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46422823ac
ℹ️ 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".
| // Hard allow-list: only allow same-origin and only raw + src paths (tight security) | ||
| if (u.origin !== window.location.origin) throw new Error('cross-origin blocked'); | ||
| if (!/\/(raw|src)\//.test(u.pathname)) throw new Error('path blocked'); |
There was a problem hiding this comment.
Allow-list blocks ProcessGit viewer API fetches
The new allow-list only permits paths containing /raw/ or /src/. The ProcessGit viewer payload includes an apiUrl that points to /api/processgitviewer (see routers/web/repo/view_file.go), and embedded viewer code can legitimately use PGV_FETCH to read through that API when running in the srcdoc iframe. With this change, any such request will now hit the path blocked error, breaking viewers that depend on the API. If the intent is to keep /api/processgitviewer available, the allow-list should include that path too.
Useful? React with 👍 / 👎.
Motivation
iframe.srcdocby proxying fetches through the parent page.Description
messagehandler inweb_src/js/features/processgitviewer/index.tsto use stricter typing and acceptPGV_FETCHrequests./raw/or/src/, and surface HTTP error codes when fetch responses are not OK.PGV_FETCH_RESULTresponse shape (includingreqIdwhen present) and returnok: falseplus anerrorstring on failures.Testing
Codex Task