Repository navigation
fix(cli): match a dash-led id in linear time - #9668
Merged
Merged
Conversation
looksLikeAnId's single regex backtracked quadratically on a long dash token that ends in a non-id character (CodeQL js/polynomial-redos on the v0.9.43 release). Two linear checks with the same meaning replace it.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Low impact] This PR appears safe to merge. SummaryReplaces the overlapping repetitions in
Reviews (1) · Last reviewed commit: "fix(cli): match a dash-led id in linear ..." · Reviewed by Greptile |
This branch was previously deployed
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
CodeQL flagged
js/polynomial-redos(high) on the v0.9.43 release PR (#9660) atpackages/sim-cli/src/runtime/build.ts:looksLikeAnIdtested an unknown-option token with/^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/, whose two stars around the required character backtrack quadratically on a long token that fails at its end (-000…0!). The regex predates #9646/#9650 (#7176); CodeQL raised it now because those PRs rewrote the parse-error guidance around it./^-[\w-]+$/(a dash then only id characters) and/[A-Z0-9]/(at least one uppercase letter or digit).\wwithout theuflag is exactly[A-Za-z0-9_].Testing
build.test.ts, three new cases in the parse-error guidance suite:Example: sim move -- -Ab3xYz;--example);-0…0!token is answered in under 1 s.-a,-ab,-A1,-ab-c,-_-_9,-9,-x!,--Foo,-é9).build.test.ts: 64/64.tsc --noEmit -p packages/sim-cli: clean.biome check: clean.