fix: quote paths in exec command to handle workspaces with spaces#6
Open
aaronearles wants to merge 1 commit into
Open
fix: quote paths in exec command to handle workspaces with spaces#6aaronearles wants to merge 1 commit into
aaronearles wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: quote paths in exec command to handle workspaces with spaces
Summary
workspacePath(andexecutablePath) are interpolated into the shell command string without quoting insrc/util.jsline 65. When the workspace path contains spaces — common in OneDrive-synced environments likeC:\Users\...\OneDrive - CompanyName\...— the path is truncated at the first space. Gitleaks silently scans the wrong directory, finds nothing, and the extension reports "No secrets found" with no indication anything went wrong.Root Cause
Fix
Both
executablePathandworkspacePathare quoted. The executable path is also quoted as it lives inside.vscode\extensions\which may itself contain spaces on some systems.Reproduction
Tested using
gitleaks_8.19.2_windows_x64.exefrom the installed extension on Windows.Directory structure — identical
.gitleaks.tomlin all three dirs (proven by hash below),C:\temp\gitleaks\is the decoy directory that only contains a clean file:Config files are identical — eliminating config as a variable:
Control — no spaces in path, works correctly:
Bug — spaces in path, unquoted (current extension behavior). Path is truncated to
C:\temp\gitleaks, the decoy directory is silently scanned, no findings, no error:Fix — spaces in path, quoted. Correct directory scanned:
Why this matters
The failure mode is a silent false negative. When the truncated path happens to be a valid directory, gitleaks exits cleanly with no stderr output. The extension receives empty stdout and empty stderr and reports "No secrets found" — giving the user false confidence that no secrets are present.
A concrete real-world example: Windows creates two OneDrive directories side by side when a user has both personal and work/school accounts:
If a workspace lives under
OneDrive - CompanyName, the path is truncated at the first space and gitleaks silently scans the personalOneDrive\directory instead — which is valid, empty, and returns no findings. The user sees "No secrets found" with no indication the wrong directory was scanned. This is a common environment for enterprise users, making this a likely failure mode in exactly the audience this extension targets.