Commit 130e95d
committed
fix: pass gitleaks --log-opts without a shell so Windows keeps the caret
runCommand spawned with shell:true, and the range argument was written with
POSIX single quotes. With shell:true Node joins command and args into one
command line for the platform shell, and cmd.exe neither treats ' as a quote
nor leaves ^ alone. Measured through the same code path on Windows:
intended, one entry: ["--log-opts='--first-parent abc123^..def456'"]
shell:true actual: ["--log-opts='--first-parent", "abc123..def456'"]
no shell: ["--log-opts='--first-parent abc123^..def456'"]
The argument is split at the space, and the caret is deleted.
The caret is the part that matters. <sha>^..<sha> starts at the parent of
commitFrom; <sha>..<sha> starts at commitFrom. Losing it narrows the range by
one commit, and that commit is the first of the push. gitleaks then exits 0
having skipped a commit that was in scope, so on Windows the scan silently
covered less than it reported.
Dropping shell:true makes the argv identical on win32 and linux, at which point
the embedded quotes are unnecessary and are removed with it. runCommand is only
called with git and gitleaks, both native executables; spawn without a shell
resolves both through PATH on Windows, verified locally.
The test reads spawn.mock.calls[1] and asserts the exact argv entry, that no
argument contains a quote, and that shell is not true. It fails on the
unmodified tree and passes with the change.
resolves #16751 parent 2696ca4 commit 130e95d
2 files changed
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
171 | 174 | | |
172 | 175 | | |
173 | 176 | | |
174 | | - | |
| 177 | + | |
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
160 | 194 | | |
161 | 195 | | |
162 | 196 | | |
| |||
0 commit comments