Repository navigation
test(security): escape every regex metacharacter in the icon-map identifier match (CodeQL #1166, #1167) - #18057
Merged
diegosouzapw merged 1 commit intoOct 24, 2026
Conversation
…tifier match (CodeQL #1166, #1167) tests/unit/icon-map-object-values.test.ts built `\bNAME\b` matchers with `name.replace(/\$/g, "\\$")`, which CodeQL js/incomplete-sanitization flags because backslashes and the other metacharacters stay unescaped. The names are JS identifiers, so only `$` could occur, but the shared identifierRe() helper now escapes the full set (same pattern as #16832) and both call sites use it. The test still passes 3/3.
Contributor
CI Coverage Report
Coverage artifact was not available for this run. |
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.
What
tests/unit/icon-map-object-values.test.tsbuilds its\bNAME\bmatchers through oneidentifierRe()helper. The helper escapes every regex metacharacter:[.*+?^${}()|[\]\\]→\\$&, the same pattern as #16832.Why
CodeQL #1166 (line 65) and #1167 (line 77),
js/incomplete-sanitization(high), flagname.replace(/\$/g, "\\$"), which escapes$but not backslashes or the other metacharacters. The names are JS identifiers ([A-Za-z_$][\w$]*), so$was the only one that could occur. The full escape costs nothing, though, and clears both sites.Validation
tests/unit/icon-map-object-values.test.ts3/3, before and after.