ui: centralize safe external URL opening for chat images#25444
Merged
ui: centralize safe external URL opening for chat images#25444
Conversation
d79246e to
6faa2ca
Compare
Contributor
|
Landed via /landpr flow with a maintainer follow-up for test stability + changelog. What I reviewed/fixed before merge:
Targeted verification run:
Landed commits (rebase):
Merge commit:
|
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Describe the problem and fix in 2–5 bullets:
window.open(...)calls.ui/src/ui/open-external-url.ts(resolveSafeExternalUrl,openExternalUrlSafe).allowDataImage: true.scripts/check-no-raw-window-open.mjs) and wired it into UI checks (test:ui) to block raw runtimewindow.open(...)usage outside the safe helper.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
http,https,blob, anddata:image/*when explicitly allowed by the caller).javascript:,file:, non-imagedata:) are ignored for image click opens.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
https://...ordata:image/...).javascript:...ordata:text/html,...).Expected
noopener,noreferrer,opener=null).Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm lintpnpm lint:ui:no-raw-window-openpnpm --dir ui exec vitest run --config vitest.config.ts --browser.enabled=false src/ui/open-external-url.test.ts src/ui/chat/message-extract.test.ts src/ui/chat/message-normalizer.test.ts src/ui/chat/tool-helpers.test.tspnpm --dir ui builddata:image/*while rejecting non-imagedata:payloads.*.browser.test.ts) execution in this environment, because Playwright binaries are not installed locally.Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
ui/src/ui/chat/grouped-render.tsui/src/ui/open-external-url.tsscripts/check-no-raw-window-open.mjspackage.json(UI check hook)Risks and Mitigations
http/https/blob+ opt-indata:image/*), with targeted unit coverage.window.openusage.Greptile Summary
Centralizes external URL opening for chat images by introducing a shared safe-open utility (
ui/src/ui/open-external-url.ts) with protocol allowlisting (http/https/blob+ opt-indata:image/*) and tabnabbing prevention (noopener,noreferrer+opener=null). Adds guard script (scripts/check-no-raw-window-open.mjs) enforced viatest:uito block future rawwindow.open(...)calls outside the safe helper. Migration consolidates ad-hoc hardening from #18685 into a reusable, testable pattern.Key improvements:
javascript:,file:, non-imagedata:URLs)Confidence Score: 5/5
Last reviewed commit: 6faa2ca