Commit b207e09
fix(adoption-analyzer): remove polynomial ReDoS in nx-projects path regex (#4965)
* fix(adoption-analyzer): remove polynomial ReDoS in nx-projects path regex
Replace the trailing-slash regex /\/+$/ with a linear-time helper. The
regex ran on project.root (parsed from project.json/package.json, treated
as untrusted library input) and had O(n^2) backtracking on inputs with
many trailing '/' not ending in '/', flagged by CodeQL js/polynomial-redos
(alert #120, high). Behaviour is unchanged; adds a targeted test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(adoption-analyzer): cover root "." → empty prefix branch
Adds the test case suggested in review to fully cover the
buildProjectIndex conditional (root "." maps to an empty prefix
that resolves every path).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 8718148 commit b207e09
2 files changed
Lines changed: 27 additions & 1 deletion
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
105 | 125 | | |
106 | 126 | | |
107 | 127 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
96 | | - | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
0 commit comments