Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git handleBinary does not work with bare repository #3003

Closed
rgmz opened this issue Jun 23, 2024 · 0 comments · Fixed by #3004
Closed

Git handleBinary does not work with bare repository #3003

rgmz opened this issue Jun 23, 2024 · 0 comments · Fixed by #3004
Labels

Comments

@rgmz
Copy link
Contributor

rgmz commented Jun 23, 2024

Please review the Community Note before submitting

TruffleHog Version

HEAD

Description

When using TruffleHog with a bare repository, the handleBinary function fails:

$ git clone git@github.com:rgmz/example.git --mirror
$ trufflehog git file:///tmp/example.git/ --bare
🐷🔑🐷  TruffleHog. Unearth your secrets. 🐷🔑🐷

2024-06-23T17:52:37-04:00       info-0  trufflehog.git  Using concurrency       {"concurrency": 20}
2024-06-23T17:52:37-04:00       info-0  trufflehog      running source  {"with_units": true}
2024-06-23T17:52:37-04:00       info-0  trufflehog      scanning repo   {"unit": "/tmp/example.git/", "unit_kind": "dir", "path": "/tmp/example.git/"}
2024-06-23T17:52:41-04:00       error   trufflehog      waiting for command failed      {"unit": "/tmp/example.git/", "unit_kind": "dir", "error": "error waiting for command: command=/usr/bin/git -C /tmp/example.git/.git cat-file blob 8faab40266603974595b3cbdc14d245a007fa104:example_binary.exe, stderr=fatal: cannot change to '/tmp/example.git/.git': No such file or directory\n, commit=8faab40266603974595b3cbdc14d245a007fa104: exit status 128"}

This is caused by gitDir being hard-coded as path + .git, which doesn't exist for bare repositories.

cmd := exec.Command("git", "-C", gitDir, "cat-file", "blob", commitHash.String()+":"+path)

gitDir := filepath.Join(path, gitDirName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant