fix(charts): strip ECharts navigation sinks from .chart documents - #7286
Merged
Conversation
A .chart document is author-controlled and rendered with setOption() straight into the app document, including on the anonymous /f/<token> share route. confineOptionToCanvas closed the innerHTML/document.write paths but left the navigation ones open: title.link, title.sublink, and a link on a treemap or sunburst data item each reach windowOpen, which assigns the URL to location.href, so a javascript: URL executed on the app origin on one click. Drop the link keys everywhere in the walk alongside toolbox. A chart has no reason to navigate its viewer, so they are stripped rather than scheme-checked, which would still leave an open redirect on an authenticated origin.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR strengthens
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified in the changed code. The recursive confinement removes the targeted navigation keys across nested chart options, retains the intentional dataset boundary, and adds focused sanitizer and integration coverage.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/charts/spec.ts | Extends recursive chart-option confinement to remove ECharts navigation keys while preserving dataset contents. |
| apps/sim/lib/charts/spec.test.ts | Adds sanitizer and real-ECharts assertions covering navigation keys across title, hierarchical series data, base options, and media options. |
Reviews (1): Last reviewed commit: "fix(charts): strip ECharts navigation si..." | Re-trigger Greptile
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
confineOptionToCanvasclosed the ECharts DOM sinks (tooltipinnerHTML,toolboxdataView/saveAsImage) but left the navigation ones open —title.link,title.sublink, and alinkon a treemap or sunburst data item each reachwindowOpen, which assigns the URL tolocation.href.chartdocument is author-controlled and rendered withsetOption()straight into the app document (unsandboxed, unlike the HTML preview alongside it), including on the anonymous/f/<token>share route — so ajavascript:URL in one executed script on the app origin on a single clicklink/sublinkeverywhere in the walk alongsidetoolbox. A chart has no reason to navigate its viewer, so they're stripped rather than scheme-checked, which would still leave an open redirect on an authenticated origintarget/subtargetare left alone — all four call sites are guarded on a truthy link, so removing the link is sufficient and avoids collateral on any unrelatedtargetkeyType of Change
Testing
apps/sim/lib/charts/spec.test.ts— 23/23 passing; the two new tests were confirmed red against the unpatched sanitizer firstbaseOptionandmedia); the other renders through real echarts and asserts the title component resolves nolink/sublinkto hand towindowOpenbun run lint,bun run check:audits(39/39),check-block-registryall passChecklist