gitleaks scans one commit too few on Windows: shell:true corrupts the --log-opts argument
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- git, typescript
- Domain
- security
Research direction
Read src/proxy/processors/push-action/gitleaks.ts at the spawn call around line 37 and the range construction around line 174. Run the existing Windows job and the regression test described in the issue, checking that the range reaches gitleaks as one argv entry with the parent commit included on every platform.
Written by the indexing model from the issue text.
Description
Description
gitleaks.ts spawns with { cwd, shell: true } and builds the range argument with POSIX single quotes:
// src/proxy/processors/push-action/gitleaks.ts:37
const child = spawn(command, args, { cwd, shell: true });
// src/proxy/processors/push-action/gitleaks.ts:174
`--log-opts='--first-parent ${rootCommit === commitFrom ? rootCommit : `${commitFrom}^`}..${commitTo}'`,
With shell: true, Node joins the command and its arguments into a single command line and hands it to the platform shell. cmd.exe does not treat ' as a quote character, and does treat ^ as an escape character. Both facts bite here.
Measured on Windows by spawning an argv echoer through the same code path, with commitFrom = abc123 and commitTo = def456:
intended, one argv entry:
["--log-opts='--first-parent abc123^..def456'"]
actual, shell: true:
["--log-opts='--first-parent", "abc123..def456'"]
actual, no shell:
["--log-opts='--first-parent abc123^..def456'"]
Two things go wrong at once. The argument is split in two at the space, because the quotes are not quotes to cmd.exe. And the ^ is silently deleted.
Why the ^ matters
<sha>^..<sha> and <sha>..<sha> are different revision ranges. The first starts at the parent of commitFrom, the second starts at commitFrom itself. Losing the caret narrows the range by one commit, and the commit that drops out is the first commit of the push being scanned.
So on Windows this is not a crash or a visible error. gitleaks runs, exits 0, and reports no leaks, having quietly skipped a commit that was in scope. For a secret-scanning proxy that is a silent gap rather than a cosmetic bug.
Expected behavior
The range argument reaches gitleaks as a single argv entry, identical on every platform, and covers the full range including the parent commit.
Environment
Windows 10, Node 22.22.0, git-proxy at 2696ca49. Not reproducible on Linux or macOS: /bin/sh strips the quotes and leaves ^ alone, which is why CI has not caught it. The repository does run a Windows job, but nothing currently asserts on the arguments passed to spawn.
Notes
Removing shell: true fixes both symptoms, and the quotes then become unnecessary since the argument is passed as one array element. runCommand is only ever called with git and gitleaks, both native executables, and I verified spawn('git', ...) without a shell resolves correctly through PATH on Windows, so nothing depends on shell resolution here.
I have a fix and a regression test ready, and would be happy to open a PR against this issue.
- Dominant language
- TypeScript
- Stars
- 252
- Forks
- 176
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 20
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from finos/git-proxy
-
meeting
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
automation dependencies maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
meeting
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·