diff options
| author | Bryan Thompson <bthompson@anthropic.com> | 2026-06-18 22:33:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-18 22:33:29 -0500 |
| commit | a758437b06d7aa56a148f94581e2edd63266a837 (patch) | |
| tree | 04cf9ed464485b04459037e2cf65097a89917b32 /plugins/code-modernization/commands/modernize-map.md | |
| parent | cef0e3f9fec7495761faec0b7baa47f3d79cf9d5 (diff) | |
| parent | 94258c5913c482462e8c242ef3060a011a4e186d (diff) | |
Merge branch 'main' into add-learn-with-courseraadd-learn-with-coursera
Diffstat (limited to 'plugins/code-modernization/commands/modernize-map.md')
| -rw-r--r-- | plugins/code-modernization/commands/modernize-map.md | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/plugins/code-modernization/commands/modernize-map.md b/plugins/code-modernization/commands/modernize-map.md index 53668ca6..afe248ad 100644 --- a/plugins/code-modernization/commands/modernize-map.md +++ b/plugins/code-modernization/commands/modernize-map.md @@ -146,6 +146,12 @@ tpl = open(tpl_path).read() marker = "/*__TOPOLOGY_DATA__*/ null" assert marker in tpl, f"injection marker not found in {tpl_path}" data = json.dumps(json.load(open(f"{out_dir}/topology.json"))) +# topology.json is derived from UNTRUSTED source (node names come from filenames, +# observations/flows from analyzed code). The data is injected into a <script> +# block, and the HTML parser closes <script> on the literal bytes "</script>" +# regardless of JS string context — so a node named "x</script><script>…" would +# execute. json.dumps does NOT escape "<". Escape it (JSON-safe) to kill the breakout. +data = data.replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026") open(f"{out_dir}/TOPOLOGY.html", "w").write( tpl.replace(marker, "/*__TOPOLOGY_DATA__*/ " + data)) print(f"wrote {out_dir}/TOPOLOGY.html") |
