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

Not working well with pre-commit #595

Closed
chanpl opened this issue Jul 19, 2021 · 2 comments · Fixed by #649
Closed

Not working well with pre-commit #595

chanpl opened this issue Jul 19, 2021 · 2 comments · Fixed by #649
Labels
bug Something isn't working

Comments

@chanpl
Copy link

chanpl commented Jul 19, 2021

Describe the bug
Two issues I got when using gitleaks with pre-commit:

  1. When run with pre-commit run -a, gitleaks was executed multiple times.
  2. A single line of secret will generate more than one error under the same rule.

To Reproduce
To reproduce:

  1. Add the following example secret to any file in your repo
    mongodb://myDBReader:D1fficultP%40ssw0rd@mongodb0.example.com:27017/?authSource=admin

  2. Use this additional config

[[rules]]
        description = "MONGODB URI"
        regex = '''mongodb:\/\/(.*):(.*)@(.*)'''
        tags = ["secrets"]
  1. Add this hook to .pre-commit-config.yaml
    - repo: https://github.com/zricethezav/gitleaks
      rev: v7.5.0
      hooks:
          - id: gitleaks
            args: ["--additional-config", ".gitleaks.toml", "--verbose"]
  1. Run pre-commit run -a

Expected behavior
gitleaks runs only once and just report 1 error. (Since there is only one line of secret)

@chanpl chanpl added the bug Something isn't working label Jul 19, 2021
@electriquo
Copy link
Contributor

gitleaks runs only once and just report 1 error. (Since there is only one line of secret)

@chanpl: i got exactly that :)

@chanpl
Copy link
Author

chanpl commented Jul 21, 2021

gitleaks runs only once and just report 1 error. (Since there is only one line of secret)

@chanpl: i got exactly that :)

@foolioo Could you share your configuration? Are you running pre-commit run -a (against all files)?

This is my output.

$ pre-commit run -a
Detect hardcoded secrets.................................................Failed
- hook id: gitleaks
- exit code: 1

INFO[0000] opening .
INFO[0000] scan time: 428 milliseconds 438 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 447 milliseconds 648 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 449 milliseconds 139 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 446 milliseconds 720 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 439 milliseconds 843 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 399 milliseconds 714 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 443 milliseconds 292 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 408 milliseconds 734 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 424 milliseconds 577 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 429 milliseconds 260 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 381 milliseconds 430 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 419 milliseconds 698 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 398 milliseconds 474 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 394 milliseconds 347 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 382 milliseconds 189 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 374 milliseconds 423 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 360 milliseconds 135 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 362 milliseconds 918 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 336 milliseconds 933 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 354 milliseconds 867 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 335 milliseconds 281 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 344 milliseconds 225 microseconds
WARN[0000] leaks found: 1
INFO[0000] opening .
INFO[0000] scan time: 357 milliseconds 867 microseconds
WARN[0000] leaks found: 1


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
2 participants