Skip to content

CNS-108 console: DOT fix for DataFlow Viz - #38272

Merged
jdonelson merged 1 commit into
mainfrom
jdonelson/CNS-108_dataflow_viz_dot_escaping
Aug 18, 2026
Merged

jdonelson merged 1 commit into
mainfrom
jdonelson/CNS-108_dataflow_viz_dot_escaping

Conversation

@jdonelson

Copy link
Copy Markdown
Contributor

Excluding tests, 169 of 255 lines are relocated rather than new.
It's probably easier to review this on the command line with --color-moved:

git checkout jdonelson/CNS-108_dataflow_viz_dot_escaping
git diff --color-moved=zebra main...HEAD

Motivation

scopeToGv escaped only " when building DOT. A backslash in an interpolated value pairs with the inserted one to form \\, freeing the next quote to close the string early, so catalog text (operator names, LIR plan text) could inject DOT attributes. An injected href renders as an anchor in the SVG, giving script execution in the Console origin.

Fixes: https://linear.app/materializeinc/issue/CNS-108/dataflow-visualizer-doesnt-escape-properly-allowing-xss

Description

Adds dotString/dotAttributes, which escape backslashes before quotes. Every node, edge, pseudo-operator and subgraph builds its attributes through them, so no call site can interpolate raw text into an attribute position. Also covers the subgraph name, previously interpolated bare.

The pure functions move to dataflowGraph.ts so they are testable without loading d3-graphviz. Most of the diff is that move plus tests

Verification

dataflowGraph.test.ts splits emitted DOT into syntax and string context by Graphviz's own termination rule, then asserts injected text stays data in all four catalog-derived positions, that ArrangeBy[[Column(0, "id")]] round-trips, and that quote-only escaping would be caught.

Manually confirmed that visualizations still render after refactor.

catalog strings produced malformed output. Add `dotString` and
`dotAttributes`, and build every node, edge and subgraph through them, so
escaping is applied uniformly instead of per call site.

Moves the pure graph code to dataflowGraph.ts so it can be unit tested;
most of the diff is that move.

Closes: CNS-108
@jdonelson jdonelson added the A-CONSOLE Area: Console label Aug 17, 2026
@jdonelson
jdonelson requested a review from a team as a code owner August 17, 2026 20:43
@jdonelson
jdonelson requested a review from Alphadelta14 August 17, 2026 20:43
@linear-code

linear-code Bot commented Aug 17, 2026

Copy link
Copy Markdown

CNS-108

@def- def- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a test!

@Alphadelta14 Alphadelta14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like something we'd be leverage a library to do than handling ourselves. the edges are pretty sharp

return [m, enrichedRoots[0], enrichedLirOperators];
}

const noArrangementRegionColor = "#12b886";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want your constants up towards the top of the module. and don't we use UPPER_CASE_WITH_UNDERS for module consts?

* brackets and commas regardless of what the catalog reported.
*/
export function stringifyAddress(address: string[]) {
return JSON.stringify(address.map((val) => parseInt(val)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does ts support direct functions? is this not just address.map(parseInt)?

@jdonelson
jdonelson merged commit 1896656 into main Aug 18, 2026
86 checks passed
@jdonelson
jdonelson deleted the jdonelson/CNS-108_dataflow_viz_dot_escaping branch August 18, 2026 15:35
@bosconi bosconi mentioned this pull request Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CONSOLE Area: Console

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants