Repository navigation
Conversation
📝 WalkthroughWalkthroughAdds DOMPurify sanitization of translated HTML content before rendering it via dangerouslySetInnerHTML in the rerun confirmation modal, simplifies props destructuring in the RerunButton component, and adds a unit test verifying that unsafe attributes and script tags are stripped while benign markup is preserved. ChangesXSS Sanitization Fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant RerunButton
participant i18n as "t()"
participant DOMPurify
User->>RerunButton: Click "Rerun from current step"
RerunButton->>i18n: t('confirmRerunModalContent', { step: step.title })
i18n-->>RerunButton: interpolated HTML string
RerunButton->>DOMPurify: sanitize(interpolated string)
DOMPurify-->>RerunButton: sanitized HTML
RerunButton->>User: render sanitized HTML in modal
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Pipeline node names are interpolated into the rerun confirmation modal without escaping. Sanitize the rendered HTML before dangerouslySetInnerHTML, matching other dataflow UI components. Fixes infiniflow#16507
0df298f to
a1f9081
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/src/pages/dataflow-result/components/rerun-button/__tests__/index.test.tsx (1)
1-13: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy liftTest doesn't exercise the actual fix.
This test only checks that
DOMPurify.sanitizesanitizes a manually-built string — it never rendersRerunButtonor callsclickFunc/Modal.show. If theDOMPurify.sanitize(...)wrapper is later removed fromindex.tsx, this test would still pass, so it doesn't actually regression-guard the vulnerability it's meant to cover.Consider rendering the component (mocking
Modal.showto capture thedangerouslySetInnerHTMLcontent) or extracting the modal HTML-building logic into a small testable function that the component calls, then asserting on that.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/dataflow-result/components/rerun-button/__tests__/index.test.tsx` around lines 1 - 13, The current test only sanitizes a hand-built string and never exercises the real RerunButton flow, so it won’t fail if the DOMPurify.sanitize call is removed from the component. Update the test to cover the actual implementation by rendering RerunButton and mocking Modal.show (or by extracting the modal HTML construction into a small helper used by clickFunc) so you can assert on the HTML passed through the real code path. Use the existing RerunButton, clickFunc, and Modal.show symbols to locate the fix and verify the sanitized content comes from the component behavior, not a standalone DOMPurify call.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@web/src/pages/dataflow-result/components/rerun-button/__tests__/index.test.tsx`:
- Around line 1-13: The current test only sanitizes a hand-built string and
never exercises the real RerunButton flow, so it won’t fail if the
DOMPurify.sanitize call is removed from the component. Update the test to cover
the actual implementation by rendering RerunButton and mocking Modal.show (or by
extracting the modal HTML construction into a small helper used by clickFunc) so
you can assert on the HTML passed through the real code path. Use the existing
RerunButton, clickFunc, and Modal.show symbols to locate the fix and verify the
sanitized content comes from the component behavior, not a standalone DOMPurify
call.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: df955b24-1cdf-46a7-b5b9-20366bfadd26
📒 Files selected for processing (2)
web/src/pages/dataflow-result/components/rerun-button/__tests__/index.test.tsxweb/src/pages/dataflow-result/components/rerun-button/index.tsx
Problem
Agent pipeline node names (
data.namein the DSL graph) are stored as plain strings and rendered in the dataflow "Rerun from current step" confirmation modal. The modal usesdangerouslySetInnerHTMLwith an i18next template whereescapeValue: false, so a malicious node name can execute script in another user's browser (stored XSS). Reported in #16507 / GHSA-9hj6-h23v-37hx.Fix
Sanitize the interpolated modal HTML with
DOMPurifybefore rendering, consistent with other dataflow UI components (chunk-card,category-panel, etc.).Verification
Fixes #16507