Repository navigation
fix: stop the CSV detection hang, clear CodeQL alerts, fix the mobile output bar - #4
Merged
Merged
Conversation
… output bar - CSV detection: the pattern could split each line at any of its commas, so on input that failed at the end the choices multiplied line by line. Sixteen lines of ",,," froze the page, and detection runs on whatever is pasted. Each line now matches in exactly one way. A regression test pins it, and it agrees with the old pattern on ordinary CSV. - Step, layer and recipe ids come from crypto.getRandomValues through one helper, randomId, instead of Math.random in thirteen places. They were never secret, but nothing that looks like an identifier is drawn from Math.random now. getRandomValues also works in the single-file build. - Strip HTML tags and the HTML/XML comment strippers repeat until nothing changes, so a removal can no longer rebuild a tag or comment out of the pieces around it. - The pane bar stays on one line: on a narrow screen its badges are clipped instead of wrapping over the header, and the output size is left to the status bar on phones.
CodeQL reads any script-tag regex as a tag filter, even in a test, and flagged the example. A plain pattern shows the same thing: one pass over "aabb" removing "ab" leaves a new "ab" behind.
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.
Why
A full check of the live site and the repository turned up one serious bug and two things that looked bad now that the project is under OWASP.
1. CSV detection could freeze the page (CodeQL
js/redos×2)The CSV detection pattern,
[^\n]*,[^\n]*per line, could split a line at any of its commas. On input that failed at the end, those choices multiplied line by line: 16 lines of,,,froze the page on the live site, and 18 took over 30 seconds in Node. Detection runs on whatever is pasted, so a 70-character string was enough.Each line now matches in exactly one way:
detection.redos.test.tspins it. Against the old pattern the test hangs; against the new one it passes.2. CodeQL alerts
js/insecure-randomnessrandomId, built oncrypto.getRandomValues. They were never secret, but no identifier is drawn fromMath.randomnow.getRandomValues(unlikerandomUUID) also works in the single-file build opened from disk.js/incomplete-multi-character-sanitizationremoveAll), so a removal cannot rebuild a tag or comment. Covered bystrip.test.ts.js/redosjs/incomplete-sanitization(report table)|is the escape cells honour and backslashes inside code spans are literal, so escaping\too would print Windows paths asC:\Users. False positive.js/missing-origin-check(engine worker)MessageEvent.originis empty there. False positive.3. Mobile output bar
On a phone, "147 bytes · 7 lines" and the AUTO-DECODED badge wrapped and spilled over the header. The pane bar now stays on one line (badges clip instead of wrapping), and the output size is left to the status bar on narrow screens.
Checked locally
npm run lint,npm run typechecknpm run test -- --run: 63 files, 1117 tests (1109 existing + 8 new)npm run build: no deprecation warnings