Skip to content

test(security): escape every regex metacharacter in the icon-map identifier match (CodeQL #1166, #1167) - #18057

Merged
diegosouzapw merged 1 commit into
release/v3.8.53from
test/codeql-1166-1167-icon-map-escape
Oct 24, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.53from
test/codeql-1166-1167-icon-map-escape

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

⚠️ base-red inherited: #17219

What

tests/unit/icon-map-object-values.test.ts builds its \bNAME\b matchers through one identifierRe() 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), flag name.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.ts 3/3, before and after.
  • prettier and eslint are clean; pre-commit hooks ran.
  • Test-only change; no production code touched.

…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.
@github-actions

Copy link
Copy Markdown
Contributor

CI Coverage Report

  • Coverage job: skipped
  • PR test policy: success

Coverage artifact was not available for this run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant