Commit 9bb1f6f
committed
fix(security): allow Windows backslash paths and add file-not-found UX [APS-18613]
Address review feedback on PR #1080:
- Remove backslash (\) from DANGEROUS_PATH_CHARS regex so legitimate Windows
absolute/relative paths (C:\Users\..., .\subdir\..., \\server\share\...) are
no longer rejected. Backslash is a path separator on Windows, not a shell
metacharacter — and the actual security boundary is execFileSync (no shell
invocation), not the regex.
- Add an fs.existsSync() check inside loadJsFile() that throws a clear
"Cypress config file not found at: <path>" error before invoking
execFileSync. This is purely a UX improvement — existsSync alone would NOT
prevent injection; the metacharacter regex + execFileSync remain the
security guarantees.
- Update unit tests:
* Add positive tests for Windows-style absolute, Program-Files (with
spaces), relative (.\subdir\...) and UNC (\\server\share\...) paths
* Add a positive test in loadJsFile that exercises the same Windows paths
end-to-end without throwing
* Add a test for the new file-not-found path that confirms execFileSync
is NOT invoked when the file is missing
* Update existsSync call-count assertion from calledOnce to calledTwice
(UX check + cleanup unlink)
Resolves: APS-186131 parent 6dbf8f9 commit 9bb1f6f
2 files changed
Lines changed: 60 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
208 | 219 | | |
209 | 220 | | |
210 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
52 | 68 | | |
53 | 69 | | |
54 | 70 | | |
| |||
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
85 | | - | |
| 101 | + | |
86 | 102 | | |
87 | | - | |
| 103 | + | |
88 | 104 | | |
89 | 105 | | |
90 | 106 | | |
| |||
94 | 110 | | |
95 | 111 | | |
96 | 112 | | |
97 | | - | |
| 113 | + | |
| 114 | + | |
98 | 115 | | |
99 | 116 | | |
100 | 117 | | |
| |||
115 | 132 | | |
116 | 133 | | |
117 | 134 | | |
118 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
119 | 162 | | |
120 | 163 | | |
121 | 164 | | |
| |||
0 commit comments