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

--no-git scans .git directory, finds false positives #474

Closed
paul-m opened this issue Dec 4, 2020 · 1 comment
Closed

--no-git scans .git directory, finds false positives #474

paul-m opened this issue Dec 4, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@paul-m
Copy link

paul-m commented Dec 4, 2020

Describe the bug

I want to scan the local files in my repo as a CI step.

With gitleaks 7 I could maybe use this:

% gitleaks --path . --config-path ./gitleaks.toml --no-git

However, since I just told gitleaks this is not a git repo, it starts scanning .git/, and finds false positives in the git commit SHAs.

The workaround is to delete .git as a first step, but this could be counter-productive, depending on needs.

To Reproduce

Within a git repo, issue this command:

% gitleaks --path . --config-path ./gitleaks.toml --no-git -v

The -v report will (might?) show you false-positive secrets that exist within the .git directory, such as:

{
	"line": "4bfc48ecc1abf2146e5180fb9e1fbc7b04bea803 add733dc5f1c0bb1a338986c74babe42727cbcb3 [...]",
	"lineNumber": 6,
	"offender": "fb9e1fbc7b04bea803 add733dc5f1c0bb1a338986c74babe42727",
	"commit": "0000000000000000000000000000000000000000",
	"repo": "",
	"repoURL": "",
	"leakURL": "",
	"rule": "Facebook Secret Key",
	"commitMessage": "",
	"author": "",
	"email": "",
	"file": ".git/logs/refs/remotes/origin/[some branch name]",
	"date": "1970-01-01T00:00:00Z",
	"tags": "key, Facebook"
}

Note that this is a false positive on a git commit SHA.

Expected behavior
gitleaks should probably ignore the .git directory when using --no-git, or should add another option like --no-git-ignore-git-directory. Hopefully with a better name than that.

Basic Info (please complete the following information):

  • OS: Mac OS X
  • Gitleaks Version: 7.0.1.

Additional context
Add any other context about the problem here.

cc @zricethezav

@paul-m paul-m added the bug Something isn't working label Dec 4, 2020
@zricethezav zricethezav self-assigned this Dec 5, 2020
@zricethezav zricethezav mentioned this issue Dec 5, 2020
3 tasks
@zricethezav
Copy link
Collaborator

@paul-m Thanks for raising this issue. By default if --no-git is set then a global allowlist regex: .git$ is appended to the config. This will prevent .git dirs from being scanned.

Should be fixed in https://github.com/zricethezav/gitleaks/releases/tag/v7.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants