Repository navigation
fix(charts): strip title markup to a fixpoint, not one pass (code-scanning 4, 5) - #119
Merged
hyperpolymath merged 1 commit intoOct 14, 2026
Conversation
…nning 4, 5) Both open code-scanning alerts are the same rule, js/incomplete-multi-character-sanitization (CWE-020/080/116, high), on the same shape: text.replace(/<[^>]+>/g, '') stripping the pseudo-HTML Plotly accepts in titles. One pass can reintroduce the dangerous sequence — "<scr<script>ipt>" loses its inner tag and the halves join into a fresh "<script>" — so the strip now lives in one shared helper, stripHtmlTags in utils/text.ts, and repeats until the text stops changing. Behaviour on ordinary titles (CO<sub>2</sub>, <b>, <br>) is identical: the second pass finds nothing and changes nothing. Used at both flagged sites — the pane title width measurement in figure/charts.ts and the report figure title in components/AnalysisChart.tsx — and pinned by new tests in utils/text.test.ts covering the split-tag case, normal markup, and bare ">" text. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 4
✨ Finishing Touches: 💡 1
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
❌ Failed to create Coding Agent finishing-touch task. Please try again. |
13 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.



What this changes
Both open code-scanning alerts — 4 and 5 — are the same rule,
js/incomplete-multi-character-sanitization(high, CWE-020/080/116), on the same shape:text.replace(/<[^>]+>/g, '')stripping the pseudo-HTML markup Plotly accepts in titles. A single pass is not a sanitizer: in"<scr<script>ipt>"the inner tag is removed and the halves join into a fresh<script>.The strip now lives in one shared helper,
stripHtmlTagsinfrontend/src/utils/text.ts, which repeats the replacement until the text stops changing — CodeQL's documented remedy, and a fixpoint by construction. It is used at both flagged sites:frontend/src/figure/charts.ts— the pane title width measurement (alert 5),frontend/src/components/AnalysisChart.tsx— the report figure's default title (alert 4).Behaviour on ordinary titles is identical
Titles like
CO<sub>2</sub>or<b>run</b>come out exactly as before: the second pass finds nothing and changes nothing. Bare>in a title ("p > 0.05") is untouched, as it always was.Tests
New
frontend/src/utils/text.test.tspins the split-tag case (<scr<script>ipt>...leaves no complete tag), normal markup, and unchanged plain text. Run them with, fromfrontend/:Both pass locally, as does
bun run build(tsc && vite build): 42/42 tests across 7 files.What this leaves out
No other sanitization sites exist in the frontend (
grep '<\[^>]' frontend/srcfinds only these two), no dependency is added (the alternative,sanitize-html, is not needed for stripping markup from plain title text), and nothing outside the frontend is touched. The branch is a single commit off the currentmaintip.Versions tested
bun 1.4.3 (the local mise shim; CI installs the version pinned in
config/defaults/tool_versions.yml). Julia and R are untouched by this change.Note: this commit is unsigned — the signing key's passphrase was not available in the session that produced it. Amend/rebase to sign if the fork's history requires it.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe vibe@mistral.ai