Skip to content

fix(shared): trim with a linear loop instead of a backtracking regex - #239

Merged
josue-commits merged 1 commit into
developfrom
fix/codeql-trim-regex
Oct 14, 2026
Merged

josue-commits merged 1 commit into
developfrom
fix/codeql-trim-regex

Conversation

@josue-commits

Copy link
Copy Markdown
Contributor

CodeQL flags three js/polynomial-redos alerts on the release PR (#238): /\/+$/ in form-links.ts and in apiCurl, and /^-+|-+$/g in apiAnchor.

Their inputs are server configuration and fixed route strings, so none was exploitable. A short linear loop does the same job and clears the alerts.

  • New packages/shared/src/trim.ts with trimTrailing and trimChar (not exported from the package index).
  • The three sites use it; behavior is unchanged (existing form-links and api-reference specs pass).
  • trim.spec.ts covers the edge cases and a 200,000-character run.

🤖 Generated with Claude Code

CodeQL flagged /\/+$/ and /^-+|-+$/ as polynomial ReDoS in form-links
and the API reference. Their inputs are server config and fixed route
strings, so nothing was exploitable, but the loops are just as short.

Signed-off-by: Josue Hernandez <josue@daptatech.com>
@josue-commits
josue-commits merged commit 6d85e99 into develop Oct 14, 2026
6 checks passed
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