fix(#266): validate share-link spec.view before writing resultView#273
Merged
Conversation
The share-link bootstrap wrote `queryView(spec)` (and a role preview) into `app.state.resultView` with only a legacy `chart`→`panel` remap and no enum check. The v2 tagged decode (`core/share.js`) passes `spec.view` through verbatim, so a crafted share link could set `resultView` to an arbitrary string. Narrow the value against `SAVED_VIEWS` (mirroring the Library-activation guard in `ui/saved-history.ts`): a Filter-role preview still wins, a persisted table/json/panel restores, legacy `chart` still maps to `panel`, and any other value silently falls back to the default view. Adds a unit test for the crafted-view case; main.ts stays at 100% coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XP1KN94N969SVMNFPdVtGg
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.
What & why
Closes #266.
src/main.ts(share-link bootstrap) wrotequeryView(spec)— the share'sspec.view— intoapp.state.resultViewwith only a legacychart→panelremap and no validation against the view enum. The v2 tagged decode
(
core/share.js→withQuerySpec) passesspec.viewthrough verbatim, so acrafted share link could set
resultViewto an arbitrary string.state.tspins the signal type at compile time only; the
.js-era glue left the runtimeingress unguarded.
Fix: narrow the launch view against
SAVED_VIEWSbefore assigning, mirroringthe Library-activation guard in
ui/saved-history.ts:rolePreview),table/json/panelrestores,view: "chart"still maps topanel(load-bearing — the v2 decodepath skips
upgradeSavedQuery, unlike Library rows),issue deferred: fall back, consistent with the sibling path, no new diagnostic
surface).
Adds a unit test for the crafted-view case (
view: "javascript:alert(1)"→stays
table).main.tsremains at 100% coverage; all 2867 tests pass.Checklist
npm testpasses (the per-file coverage gate is non-negotiable)npm run buildsucceeds (single-filedist/sql.html)src/core/, network insrc/net/(injected fetch), DOM insrc/ui/CHANGELOG.md([Unreleased]) updated if behavior or the deployed surface changed🤖 Generated with Claude Code