✅ Add ReDoS regression tests - #9
Merged
Merged
Conversation
- Cover link, XML tag, and trailing whitespace detection - Assert adversarial inputs finish well inside a time budget - Cover CRLF frontmatter, colons in values, and continuation lines Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Adds regression tests for the ReDoS fixes in #8.
src/validate/micro-templates.jshad no test file before this change.Changes
test/validate/micro-templates.test.jscovering link detection, XML tag detection, trailing whitespace, non-string input, and adversarial timingtest/core/frontmatter.test.jswith CRLF frontmatter, colons inside values, continuation lines, and a long space runAffected area
Tests.
Checklist
npm run formatpasses with no unstaged diffs.npm testpasses with no new errors.README.mdis updated when CLI options, validation rules, or package exports change. Not applicable; no user-facing behavior changes.package.jsonexportsandfilesare updated when modules are added, moved, or removed. Not applicable; tests are not published.Security checklist
npm audit --audit-level=highreports no new high or critical findings.Verification
Each new test was run against the pre-fix code to confirm it genuinely fails without #8:
(text || "").replace is not a functionnullThe timing budget is 1000 ms against a post-fix runtime under 1 ms, so a loaded CI runner will not make these flaky.
The frontmatter long-space-run case passes against old code too, because that path was never reachable. It is asserted for correctness only, not as a timing guard, to avoid implying a regression it cannot catch.
npm testreports 39 passing tests across 14 suites, 0 failuresnpx prettier --config-precedence prefer-file --check .reports no driftStack
Part of a stacked PR series fixing the polynomial ReDoS code scanning alerts (bottom to top):
stoe/fix-redos-patterns)stoe/add-redos-tests)