Trying to implement trufflehog in my pre-commit however, receiving an entry point error- does any have an example pre-commit config file?

Viewed 34

I am trying to use Truffle hog credentials scanner every time I run a commit. Below is both my .precommit config file and error in the terminal.

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: check-yaml
    -   id: end-of-file-fixer
    -   id: trailing-whitespace
-   repo: https://github.com/psf/black
    rev: 22.1.0
    hooks:
    - id: black
      additional_dependencies: ['click==8.0.4']
-   repo: local
    hooks:
    - id: pytest-check
      name: pytest-check
      stages: [commit]
      types: [python]
      entry: pytest
      language: system
      pass_filenames: false
      always_run: true
      repos:
- repo: local
  hooks:
    - id: trufflehog
      name: TruffleHog
      description: Detect secrets in your data.
      entry: bash -c 'docker run -v "$(pwd):/workdir" -i --rm trufflesecurity/trufflehog:latest git file:///jonas_asad --only-verified --fail'
      language: system
      stages: ["commit", "push"]

And the error is:

 pre-commit install && git add . && git commit -m "test"
pre-commit installed at .git\hooks\pre-commit
[WARNING] Unexpected key(s) present on local => pytest-check: repos
Check Yaml...............................................................Passed
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
black................................................(no files to check)Skipped
pytest-check.............................................................Passed
TruffleHog...............................................................Failed
- hook id: trufflehog
- exit code: 1

time="2022-09-22T13:16:38Z" level=fatal msg="Failed to scan Git." error="could open repo: /jonas_asad: repository does not exist"

I cant figure this out- if you have a working configuration file please show how yours works.

Be much appreciated,

1 Answers

I found that this worked

- repo: local
  hooks:
    - id: semgrep
      name: Semgrep Docker
      description: Detect secrets in your data.
      entry: bash -c 'docker run -v "$(pwd):/src" -i --rm returntocorp/semgrep semgrep scan --json . --config=auto --output=semgrep_results.json'
      language: system
      stages: ["commit", "push"]
Related