Problem
Three high-severity CodeQL alerts are open on main, all js/incomplete-sanitization: "This does not escape backslash characters in the input." The same code is on v2/main.
| Alert |
Location |
Code |
| #74 |
scripts/dependabot-alerts.mjs:435 |
const cell = (value) => String(value).replace(/|/g, "\|"); |
| #75 |
scripts/dependabot-alerts.mjs:679 |
a.summary.replace(/|/g, "\|") |
| #76 |
scripts/sdk-watch.mjs:442 |
const cell = (value) => String(value).replace(/|/g, "\|"); |
Each helper escapes | for a Markdown table cell but not \. A value ending in a backslash (for example abc\) yields abc\\| after escaping, which re-exposes the pipe and breaks the table row. The values include advisory summaries and upstream text, so they are not fully under our control. The impact is limited to the rendering of bot-filed issue bodies, but the alerts are real and will keep flagging every release PR.
Change
- Escape the backslash before the pipe (
.replace(/\\/g, "\\\\").replace(/\|/g, "\\|")), in one shared helper both scripts import rather than three copies.
- Add a test case with a trailing backslash.
Acceptance
Part of tracker #2543. Needs no credential; can start now.
Problem
Three high-severity CodeQL alerts are open on
main, alljs/incomplete-sanitization: "This does not escape backslash characters in the input." The same code is onv2/main.scripts/dependabot-alerts.mjs:435const cell = (value) => String(value).replace(/|/g, "\|");scripts/dependabot-alerts.mjs:679a.summary.replace(/|/g, "\|")scripts/sdk-watch.mjs:442const cell = (value) => String(value).replace(/|/g, "\|");Each helper escapes
|for a Markdown table cell but not\. A value ending in a backslash (for exampleabc\) yieldsabc\\|after escaping, which re-exposes the pipe and breaks the table row. The values include advisory summaries and upstream text, so they are not fully under our control. The impact is limited to the rendering of bot-filed issue bodies, but the alerts are real and will keep flagging every release PR.Change
.replace(/\\/g, "\\\\").replace(/\|/g, "\\|")), in one shared helper both scripts import rather than three copies.Acceptance
scripts/lib/Part of tracker #2543. Needs no credential; can start now.