Skip to content
How it works

Scanner deep dive

Every way to run the free trufflehog CLI: on a computer, in Docker, in CI or as a git hook. For TruffleHog Enterprise, see Deploy Enterprise.

Verified against commit 2325546, the same TruffleHog version as the rest of Atlas. Open a tag to see its evidence.

What the tags after each sentence mean
From source
Read from TruffleHog's repository at the pinned commit. Shown as a small code icon after the sentence; it opens the exact lines.
Inferred
A conclusion the code supports but does not state. The reason and the code it rests on are listed.
From docs
TruffleHog Enterprise is not in the open-source code. Quoted from Truffle Security's docs, with the date it was read.
From the owner
Stated by the site owner from first-hand knowledge, with the date. Not in public code or docs.

Every way to deploy it

Open source only

Commands come from the open-source repository's README and PreCommit.md. Enterprise is deployed differently and is not part of this list.

New to Terminal? Words you'll see

To open Terminal on a Mac, press Command and Space, type Terminal and press Return. Paste a command, press Return and wait for it to finish.

Terminal and shell
Terminal is the Mac app where you type commands. The shell is the program inside it that runs them; recent Macs use one called zsh.
Command
A program you run by typing its name, such as trufflehog or brew.
PATH
The list of folders your shell searches when you type a command. If a program isn't in one of them, the shell says it can't find it.
Package manager
A tool that downloads programs, puts them where your shell can find them, and updates them. Homebrew is one for Mac and Linux.
Git hook
A small script Git runs by itself at a set moment, such as right before each commit.
CI
Continuous integration: checks that run on a server, such as GitHub Actions, every time code is pushed.
Container (Docker)
A sealed box that runs a program without installing it on your computer.
Checksum and cosign
A checksum is a fingerprint of a download. cosign checks the fingerprint was signed by the project, so you know the file wasn't swapped.

Compare them side by side

The Docker commands share one row. Green means it runs or blocks on its own; amber means there's a catch.

1aInstall it on a computer

  • No, you run itNo
    Works on
    Mac
    Needs installing
    Yes
    Setup
    One command
    How it updates
    brew upgrade
  • No, you run itNo
    Works on
    Linux, Mac, Windows (WSL)
    Needs installing
    Yes
    Setup
    One command
    How it updates
    Run it again, or pin a tag
  • No, you run itNo
    Works on
    Linux, Mac, Windows
    Needs installing
    Yes, by hand
    Setup
    A few manual steps
    How it updates
    Download again by hand
  • No, you run itNo
    Works on
    Anywhere Go runs
    Needs installing
    Yes, plus Go
    Setup
    Three commands
    How it updates
    Pull and rebuild
  • No, your code calls itNo
    Works on
    Go projects
    Needs installing
    Added to your Go code
    Setup
    Your own code
    How it updates
    Update the Go module

1bTry it without installing (Docker)

  • No, you run itNo
    Works on
    Unix shells, Windows Command Prompt and PowerShell, Apple-chip Mac
    Needs installing
    No, Docker only
    Setup
    One command
    How it updates
    :latest pulls the newest image

2aCheck every push or pull request (CI/CD)

  • Every push or pull requestFails the build
    Works on
    Any CI that runs commands
    Needs installing
    On the runner
    Setup
    One command in your pipeline
    How it updates
    Whatever installs it on the runner
  • Every push or pull requestFails the build
    Works on
    GitHub
    Needs installing
    No, runs the Docker image
    Setup
    One workflow file
    How it updates
    Pin one with the version input
  • GitLab CI
    Merge requestsFails the job if pipefail is on
    Works on
    GitLab
    Needs installing
    The job installs it
    Setup
    One job in .gitlab-ci.yml
    How it updates
    The job's install script runs each time

2bStop secrets before they're committed (git hooks)

  • Every commitStops the commit
    Works on
    Every repo on one machine
    Needs installing
    Yes, or Docker
    Setup
    Four steps, once per machine
    How it updates
    Follows your installed trufflehog
  • Every commit and pushStops the commit or push
    Works on
    One repo
    Needs installing
    Yes, plus the pre-commit tool
    Setup
    A config file and two commands
    How it updates
    Follows your installed trufflehog
  • Every commitStops the commit (not the Docker line as written)
    Works on
    One JavaScript repo
    Needs installing
    Yes, or Docker
    Setup
    Two commands and a hook file
    How it updates
    Follows your installed trufflehog
  • Every commitNo, reports only
    Works on
    Any hook setup
    Needs installing
    Yes, or Docker
    Setup
    Swap one line in your hook
    How it updates
    Follows your installed trufflehog
  • Every push to the serverCan reject the push
    Works on
    A git server you control
    Needs installing
    On the server
    Setup
    Your own script; no ready-made example
    How it updates
    Follows the server's trufflehog

Step 1: Get TruffleHog open source

1aInstall it on a computer

For running scans yourself from a terminal. Each of these puts the trufflehog command on the machine.

Homebrew
Macs. The easiest to install and to keep updated, with brew upgrade.
Install script
Linux, servers, WSL and CI images, or any machine without Homebrew.
Release download
No package manager, or a locked-down machine where you place the program by hand.
Build from source
Only to run your own code changes, test something unreleased or contribute. Needs Go installed.
Go library (developers)
For developers building TruffleHog into their own Go tools. The README warns the public APIs may change, with no stability guarantee yet.
Commands and details (7)
Homebrew
Command
brew install trufflehog
Homebrew, step by step for beginners

In plain words: Homebrew is like an app store you use from Terminal. The README gives this one command for macOS users.

Read first: No brew? Install Homebrew from brew.sh first. When it finishes it prints a few setup lines. Run them too, or brew won't be found.

What each part does

  1. brewHomebrew, the program that does the installing.
  2. install trufflehogDownload TruffleHog and put it in Homebrew's folder, which your shell searches once Homebrew is set up.
What you'll see
Progress lines while it downloads, then your prompt comes back. The first install can take a minute.
How it updates
brew upgrade updates it.
Can a git hook find it?
Yes. A hook that looks for the trufflehog command finds it once Homebrew is set up.
What you're trusting
Homebrew's package of TruffleHog's release. The easiest of the five to keep updated.
Install script
Command
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
Check the signature first (needs cosign)
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -v -b /usr/local/bin
Pin a specific version
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin <ReleaseTag like v3.56.0>
  • -v checks TruffleHog's signed checksum before installing, when you need proof the file is genuine. It needs cosign installed.
  • Replace <ReleaseTag like v3.56.0> with a real release tag to pin that version, so every run uses the same one.
Install script, step by step for beginners

In plain words: The README gives a script that downloads and installs TruffleHog. One command fetches the script and runs it straight away.

Read first: This runs code from the internet on your computer. Read the script first, or use the version that checks TruffleHog's signature (Other options to note).

What each part does

  1. curl -sSfL <address>curl downloads the script. s = quiet, S = still show errors, f = stop if the download fails, L = follow redirects.
  2. | shThe pipe hands the downloaded script straight to sh, which runs it. This is the moment you trust it.
  3. -s --Tells sh to run the script it was handed, and that everything after -- is for the script, not for sh.
  4. -b /usr/local/binThe script's own option: the folder to install into.
What you'll see
A few download messages, then your prompt comes back. "Permission denied" means that folder needs admin rights; pick a folder you own that's on your PATH instead.
How it updates
Run the command again for the newest release, or add a release tag to get a specific one.
Can a git hook find it?
Yes, if the folder after -b is on your PATH.
What you're trusting
The script and the release it downloads. TruffleHog signs a checksum file you can check.
Release download
Check the checksum file's signature (needs cosign)
cosign verify-blob <path to trufflehog_{version}_checksums.txt> \
--certificate <path to trufflehog_{version}_checksums.txt.pem> \
--signature <path to trufflehog_{version}_checksums.txt.sig> \
--certificate-identity-regexp 'https://github\.com/trufflesecurity/trufflehog/\.github/workflows/.+' \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com"
Then check your download against the checksums
sha256sum --ignore-missing -c trufflehog_{version}_checksums.txt
  • Download and unpack TruffleHog from its GitHub releases page.
  • To check it, also download the release's checksums file and its .pem and .sig files, then run the two commands with {version} replaced by the version you downloaded.
Release download, step by step for beginners

In plain words: You do it by hand: download the program, unpack it, and move it into a folder Terminal searches. No installer.

What each part does

  1. Open the releases page and pick the newest release.
  2. Download the file for your computer. darwin means macOS; arm64 is an Apple chip and amd64 an Intel chip.
  3. Double-click the download to unpack it. Inside is the trufflehog program.
  4. Move trufflehog into a folder on your PATH, then run the check below.
What you'll see
Nothing happens in Terminal until the check. The check tells you whether the move worked.
How it updates
Download the newer release by hand.
Can a git hook find it?
Yes, after you move it into a folder on your PATH.
What you're trusting
The file from TruffleHog's releases page. The README shows how to check its signed checksum with cosign.
Build from source
Commands
git clone https://github.com/trufflesecurity/trufflehog.git
cd trufflehog; go install
Build from source, step by step for beginners

In plain words: You download TruffleHog's code and build the program yourself with Go, the language it's written in. Only worth it to change TruffleHog or test something unreleased.

Read first: You need Go installed first. go.mod asks for Go 1.26.

What each part does

  1. git clone <address>Copy TruffleHog's code onto your computer, into a new folder named trufflehog.
  2. cd trufflehogMove into that folder.
  3. go installBuild the program and put it in Go's bin folder, usually ~/go/bin. That folder must be on your PATH.
What you'll see
Very little output while it builds, which can take a few minutes. Your prompt comes back when it's done.
How it updates
Pull the newest code and run go install again.
Can a git hook find it?
Yes, if Go's bin folder is on your PATH.
What you're trusting
TruffleHog's code at whatever version you checked out, built on your machine.
Go library (developers)
  • The README gives no setup steps for library use, only the stability warning.

1bTry it without installing (Docker)

For trying it out, or when nothing should be installed on the machine. TruffleHog runs in a container that is deleted when the scan ends.

Docker
One command, with a version for each terminal: Mac and Linux, Windows Command Prompt, Windows PowerShell, and Apple-chip Macs.
Commands and details (4)
Docker

Pick your terminal

Unix shells are the terminals on Linux and Mac, such as bash and zsh.

Command
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys
Docker, step by step for beginners

In plain words: Docker runs programs inside a sealed box called a container. TruffleHog runs in it, scans, and the box is deleted. Nothing is installed on your computer.

Read first: This README command is an example scan of TruffleHog's public test repository. It shows the tool running; it doesn't install anything.

What each part does

  1. docker runStart a container: a sealed box that runs a program.
  2. --rmDelete the container when it finishes, so nothing is left behind.
  3. -itConnect it to your Terminal so you see the output and can stop it with Control-C.
  4. -v "$PWD:/pwd"Share the folder you're in with the container, where it appears as /pwd. This example doesn't use it; you'd need it to scan your own files.
  5. trufflesecurity/trufflehog:latestWhich program to run: TruffleHog's official image, newest version.
  6. github --repo <address>What TruffleHog should do: scan that public GitHub repository.
What you'll see
The first time, Docker downloads the image. Then TruffleHog prints what it finds and the container disappears.
How it updates
The :latest tag gets the newest image when one is published.
Can a git hook find it?
Not a hook that looks for the trufflehog command on your computer. PreCommit.md also shows a hook written to run this Docker image instead.
What you're trusting
Docker's copy of TruffleHog's official image. Docker must already be installed and running.
  • All four README commands scan TruffleHog's public test repository as an example. To scan your own files, share the folder with -v and point TruffleHog at the path inside the container.
Check it worked
command -v trufflehog
trufflehog --version

Done when: The first line prints where the program lives. The second prints its version, from the --version flag the CLI defines.

If nothing prints, try these in order

  • Close Terminal, open a new window and run the check again. A new window reloads the folders your shell searches.
  • If brew itself isn't found, Homebrew's setup step was skipped. Its post-installation steps give the one line to add.
  • If you used Docker, nothing printing is expected: it runs in a container, not on your computer.

Step 2: Make it run automatically (optional)

2aCheck every push or pull request (CI/CD)

For catching secrets on every push or pull request, before they are merged.

Any CI platform
Any pipeline that can run a command. It scans only the branch's new commits and, with --fail, exits 183 so the build fails when it prints a result.Scanning a CI server itself (such as Jenkins) is different: it's a source
GitHub Action
GitHub repositories. TruffleHog's own Action runs its Docker image, so nothing is installed on the runner.
GitLab CI
GitLab repositories. A ready-made job that installs TruffleHog with the install script and scans merge requests.
Commands and details (7)
Any CI platform
Command
trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --fail
  • The README names CircleCI's CIRCLE_BRANCH and Travis CI's TRAVIS_PULL_REQUEST_BRANCH as ways to fill in --branch. If the branch is already checked out, --branch HEAD is enough.
  • The runner needs the trufflehog command, for example from the install script or the Docker image.
GitHub Action
Basic workflow
Show example (18 lines)
on:
  push:
    branches:
      - main
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Secret Scanning
      uses: trufflesecurity/trufflehog@main
      with:
        extra_args: --results=verified,unknown

The README's example adds --results=verified,unknown through extra_args. Without it, the action uses the default, which includes unverified results.

  • The README's Action section also notes that TruffleHog detects Canarytokens (canarytokens.org) statically.
  • --sarif writes results as SARIF, which GitHub code scanning shows on pull requests. SARIF results are held in memory until the scan ends.
More GitHub Action setups (4)
Shallow clone (faster)
Show example (19 lines)
...
      - shell: bash
        run: |
          if [ "${{ github.event_name }}" == "push" ]; then
            echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
            echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
          fi
          if [ "${{ github.event_name }}" == "pull_request" ]; then
            echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
            echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
          fi
      - uses: actions/checkout@v3
        with:
          ref: ${{env.branch}}
          fetch-depth: ${{env.depth}}
      - uses: trufflesecurity/trufflehog@main
        with:
          extra_args: --results=verified,unknown
...

Fetches only the pushed or pull request commits plus 2, so a standalone scan workflow checks out less.

Every input
Show example (15 lines)
- name: TruffleHog
  uses: trufflesecurity/trufflehog@main
  with:
    # Repository path
    path:
    # Start scanning from here (usually main branch).
    base:
    # Scan commits until here (usually dev branch).
    head: # optional
    # Extra args to be passed to the trufflehog cli.
    extra_args: --log-level=2 --results=verified,unknown
    # Scan with a specific TruffleHog version (default: latest).
    version:
    # Docker image to pull. Override to use a registry mirror (default: ghcr.io/trufflesecurity/trufflehog).
    image:

base and head map to --since-commit and --branch. version pins a TruffleHog version and image points at a registry mirror.

Scan the entire branch
- name: scan-push
        uses: trufflesecurity/trufflehog@main
        with:
          base: ""
          head: ${{ github.ref_name }}
          extra_args: --results=verified,unknown

An empty base scans the whole branch instead of only the new commits.

Upload results to GitHub code scanning (SARIF)
- name: TruffleHog
  run: trufflehog filesystem . --sarif --no-verification > results.sarif
- name: Upload SARIF results
  uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: results.sarif

This runs the trufflehog command, not the Action, so the runner needs TruffleHog installed. With --no-verification nothing is checked live.

GitLab CI
.gitlab-ci.yml job
Show example (16 lines)
stages:
  - security

security-secrets:
  stage: security
  allow_failure: false
  image: alpine:latest
  variables:
    SCAN_PATH: "." # Set the relative path in the repo to scan
  before_script:
    - apk add --no-cache git curl jq
    - curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
  script:
    - trufflehog filesystem "$SCAN_PATH" --results=verified,unknown --fail --json | jq
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  • --fail makes TruffleHog exit with code 183 when it prints any result. That means any status that passed --results, not only verified ones. The README says "if valid credentials are found".
  • The README's CI example scans only the new commits, with --since-commit and --branch, and uses --results=verified,unknown with --fail.
  • The repository ships a GitHub Action. It runs the Docker image as a git scan of the checked-out repository with --fail and GitHub Actions output. It passes no --results, so it uses the default and fails on unverified results too. Extra flags go in its extra_args input.
  • The README's GitLab CI example runs a filesystem scan with --results=verified,unknown --fail on merge requests.
  • That example pipes the output into jq. Unless the job's shell has pipefail turned on, the job sees jq's exit code instead of 183 and will not fail when secrets are found, so check your runner's shell settings.

2bStop secrets before they're committed (git hooks)

For stopping a secret before it leaves a developer's laptop. Every hook needs TruffleHog from Step 1, installed on the machine unless the hook runs the Docker image.

Git hooksPath (every repo on the machine)
One setup covers every repository on the computer, with nothing to add to each repo.
pre-commit framework (one repo)
Teams that already manage hooks with the pre-commit tool. The config lives in the repository, so everyone who installs it gets the same hook.
Husky (JavaScript projects)
npm or yarn projects that already manage git hooks with Husky.
Audit mode (report, don't block)
To try a hook before enforcing it. It prints what it finds but never stops a commit, because --fail is removed.
Server-side pre-receive hook
A git server where you can add your own pre-receive hook, to check pushes centrally. The CLI's git --bare flag is meant for this.
Commands and details (20)
Git hooksPath (every repo on the machine)
1. Make a hooks folder
mkdir -p ~/.git-hooks
2. Make the hook file runnable
touch ~/.git-hooks/pre-commit
chmod +x ~/.git-hooks/pre-commit

3. Pick a hook script

Hook script, auto-configured
#!/bin/sh
export TRUFFLEHOG_PRE_COMMIT=1
trufflehog git file://.
4. Point Git at the folder
git config --global core.hooksPath ~/.git-hooks
  • Git then uses this folder instead of each repository's own .git/hooks, so hooks a repo already had stop running.
pre-commit framework (one repo)
1. Install the pre-commit tool
# Using pip (Python)
pip install pre-commit

# Using Homebrew (macOS)
brew install pre-commit

# Using conda
conda install -c conda-forge pre-commit

2. Pick a .pre-commit-config.yaml

.pre-commit-config.yaml, auto-configured
repos:
  - repo: local
    hooks:
      - id: trufflehog
        name: TruffleHog
        description: Detect secrets in your data.
        entry: bash -c 'trufflehog git file://.'
        language: system
        stages: ["pre-commit", "pre-push"]
3. Install the hook in your clone
pre-commit install
  • Both configs run on pre-push as well as pre-commit.
Husky (JavaScript projects)
1. Add Husky to the project
# npm
npm install husky --save-dev

# yarn
yarn add husky --dev
2. Turn on Husky's hooks
# npm
npx husky init

3. Pick a hook

Hook, auto-configured
echo "trufflehog git file://." > .husky/pre-commit
Audit mode (report, don't block)

Pick how you run TruffleHog

Audit command (installed trufflehog)
trufflehog git file://. --since-commit HEAD --results=verified,unknown 2>/dev/null
  • It also hides TruffleHog's progress output (2>/dev/null), so only results are printed.
  • With the pre-commit framework, add verbose: true during audit mode, or the hook passes silently and you see nothing.
Server-side pre-receive hook
  • For server-side pre-receive hooks, git --bare scans a bare repository. Its help text names pre-receive hooks, and the git parser passes GIT_OBJECT_DIRECTORY through when it is set.
  • Any git server that lets you run your own pre-receive hook can call it this way. Which hosting services allow custom pre-receive hooks is outside this code.
  • It switches to hook mode, for the git command only, when PRE_COMMIT, HUSKY or TRUFFLEHOG_PRE_COMMIT is set to 1, or HUSKY_GIT_PARAMS is set to any value.
  • In hook mode it sets the commit range to HEAD..HEAD, which the code says scans only staged changes, turns --fail on and trusts the local git config.
  • It also sets --results=verified,unknown, but only after the scan engine has already been built from --results.
  • So that setting has no effect: unverified results still print and still fail the commit, unless you pass --results yourself, as PreCommit.md's example does.
Tips and troubleshooting (from PreCommit.md)
  • Run git add and git commit as separate steps, so TruffleHog sees everything you're committing.
  • Avoid git commit -am, which can skip the hook for changes you haven't staged.
  • Anyone can skip the hook with --no-verify, so a hook alone doesn't enforce anything. Pair it with a CI check if you need enforcement.
  • Too many false positives? Show only verified results with --results=verified, or add a trufflehog:ignore comment to lines you've accepted.
Skip the hook for one commit
git commit --no-verify -m "Your commit message"
Hook not running? Make it executable
chmod +x .git/hooks/pre-commit
Then check whether a hooks folder is set
git config --get core.hooksPath

Reference

Every scan command

The CLI has 18 scan commands, plus analyze. multi-scan reads several sources from a config file.

CommandHelp textIn AtlasIn the code
trufflehog gitFind credentials in git repositories.Connectormain.go line 105 (opens TruffleHog source on GitHub)
trufflehog githubFind credentials in GitHub repositories.Connectormain.go line 121 (opens TruffleHog source on GitHub)
trufflehog github-experimentalRun an experimental GitHub scan. Must specify at least one experimental sub-module to run: object-discovery.Connectormain.go line 145 (opens TruffleHog source on GitHub)
trufflehog gitlabFind credentials in GitLab repositories.Connectormain.go line 154 (opens TruffleHog source on GitHub)
trufflehog filesystemFind credentials in a filesystem.Connectormain.go line 168 (opens TruffleHog source on GitHub)
trufflehog s3Find credentials in S3 buckets.Connectormain.go line 178 (opens TruffleHog source on GitHub)
trufflehog gcsFind credentials in GCS buckets.Connectormain.go line 195 (opens TruffleHog source on GitHub)
trufflehog syslogScan syslogConnectormain.go line 207 (opens TruffleHog source on GitHub)
trufflehog circleciScan CircleCIConnectormain.go line 214 (opens TruffleHog source on GitHub)
trufflehog dockerScan Docker ImageConnectormain.go line 217 (opens TruffleHog source on GitHub)
trufflehog travisciScan TravisCIConnectormain.go line 224 (opens TruffleHog source on GitHub)
trufflehog postmanScan PostmanConnectormain.go line 228 (opens TruffleHog source on GitHub)
trufflehog elasticsearchScan ElasticsearchConnectormain.go line 252 (opens TruffleHog source on GitHub)
trufflehog jenkinsScan JenkinsConnectormain.go line 264 (opens TruffleHog source on GitHub)
trufflehog huggingfaceFind credentials in HuggingFace datasets, models, spaces and buckets.Connectormain.go line 270 (opens TruffleHog source on GitHub)
trufflehog stdinFind credentials from stdin.Connectormain.go line 295 (opens TruffleHog source on GitHub)
trufflehog multi-scanFind credentials in multiple sources defined in configuration.Nonemain.go line 296 (opens TruffleHog source on GitHub)
trufflehog json-enumeratorFind credentials from a JSON enumerator input.Nonemain.go line 298 (opens TruffleHog source on GitHub)

Flags you'll see in these commands (19)

Help text is copied from TruffleHog’s code. For what verified, unverified and unknown mean, see How verification works.

FlagHelp textIn the code
--resultsSpecifies which type(s) of results to output: verified (confirmed valid by API), unknown (verification failed due to error), unverified (detected but not verified), filtered_unverified (unverified but would have been filtered out). Defaults to verified,unverified,unknown.main.go line 62 (opens TruffleHog source on GitHub)
--failExit with code 183 if results are found.main.go line 82 (opens TruffleHog source on GitHub)
--since-commitCommit to start scan from.main.go line 110 (opens TruffleHog source on GitHub)
--branchBranch to scan.main.go line 111 (opens TruffleHog source on GitHub)
--only-verifiedOnly output verified results.(hidden from --help)main.go line 61 (opens TruffleHog source on GitHub)
--no-verificationDon't verify the results.main.go line 60 (opens TruffleHog source on GitHub)
--jsonOutput in JSON format.main.go line 55 (opens TruffleHog source on GitHub)
--sarifOutput in SARIF format for upload to GitHub code scanning (e.g. via github/codeql-action/upload-sarif).main.go line 58 (opens TruffleHog source on GitHub)
--github-actionsOutput in GitHub Actions format.main.go line 57 (opens TruffleHog source on GitHub)
--trust-local-git-configTrust local git config.main.go line 116 (opens TruffleHog source on GitHub)
--bareScan bare repository (e.g. useful while using in pre-receive hooks)main.go line 113 (opens TruffleHog source on GitHub)
--no-updateDon't check for updates.main.go line 81 (opens TruffleHog source on GitHub)
--configPath to configuration file.main.go line 78 (opens TruffleHog source on GitHub)
--concurrencyNumber of concurrent workers.main.go line 59 (opens TruffleHog source on GitHub)
--log-levelLogging verbosity on a scale of 0 (info) to 5 (trace). Can be disabled with "-1".main.go line 50 (opens TruffleHog source on GitHub)
--include-detectorsComma separated list of detector types to include. Protobuf name or IDs may be used, as well as ranges.main.go line 90 (opens TruffleHog source on GitHub)
--exclude-detectorsComma separated list of detector types to exclude. Protobuf name or IDs may be used, as well as ranges. IDs defined here take precedence over the include list.main.go line 91 (opens TruffleHog source on GitHub)
--include-pathsPath to file with newline separated regexes for files to include in scan.main.go line 107 (opens TruffleHog source on GitHub)
--exclude-pathsPath to file with newline separated regexes for files to exclude in scan.main.go line 108 (opens TruffleHog source on GitHub)

Worked examples from the README (22)

The README’s Quick Start, as written. Placeholders in angle brackets are yours to fill in. Each example links to the source it scans.

Scan a repo for verified secrets
trufflehog git https://github.com/trufflesecurity/test_keys --results=verified

This source in Atlas

Scan a GitHub organization
trufflehog github --org=trufflesecurity --results=verified

This source in Atlas

Scan a GitHub organization, skipping archived repos
trufflehog github --org=trufflesecurity --exclude-archived

This source in Atlas

Scan a repo and get JSON output
trufflehog git https://github.com/trufflesecurity/test_keys --results=verified --json

This source in Atlas

Scan a GitHub repo plus its issues and pull requests
trufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments

This source in Atlas

Scan an S3 bucket (verified and unknown results)
trufflehog s3 --bucket=<bucket name> --results=verified,unknown

This source in Atlas

Scan S3 buckets using an IAM role
trufflehog s3 --role-arn=<iam role arn>

This source in Atlas

Scan a GitHub repo over SSH, in Docker
docker run --rm -v "$HOME/.ssh:/root/.ssh:ro" trufflesecurity/trufflehog:latest git ssh://github.com/trufflesecurity/test_keys

This source in Atlas

Scan files or folders
trufflehog filesystem path/to/file1.txt path/to/file2.txt path/to/dir

This source in Atlas

Scan a local git repo
git clone git@github.com:trufflesecurity/test_keys.git

This source in Atlas

Scan Google Cloud Storage buckets
trufflehog gcs --project-id=<project-ID> --cloud-environment --results=verified

This source in Atlas

Scan a Docker image (registry, local daemon or tarball)
# to scan from a remote registry
trufflehog docker --image trufflesecurity/secrets --results=verified

# to scan from the local docker daemon
trufflehog docker --image docker://new_image:tag --results=verified

# to scan from an image saved as a tarball
trufflehog docker --image file://path_to_image.tar --results=verified

This source in Atlas

Scan a Postman workspace
trufflehog postman --token=<postman api token> --workspace-id=<workspace id>

This source in Atlas

Scan a Jenkins server
trufflehog jenkins --url https://jenkins.example.com --username admin --password admin

This source in Atlas

Scan a local Elasticsearch cluster (username and password)
trufflehog elasticsearch --nodes 192.168.14.3 192.168.14.4 --username truffle --password hog

This source in Atlas

Scan a local Elasticsearch cluster (service token)
trufflehog elasticsearch --nodes 192.168.14.3 192.168.14.4 --service-token ‘AAEWVaWM...Rva2VuaSDZ’

This source in Atlas

Scan an Elastic Cloud cluster
trufflehog elasticsearch \
  --cloud-id 'search-prod:dXMtY2Vx...YjM1ODNlOWFiZGRlNjI0NA==' \
  --api-key 'MlVtVjBZ...ZSYlduYnF1djh3NG5FQQ=='

This source in Atlas

Find cross-fork objects and deleted commits on GitHub (experimental)
trufflehog github-experimental --repo https://github.com/<USER>/<REPO>.git --object-discovery

This source in Atlas

Scan a Hugging Face model, dataset, space or bucket
trufflehog huggingface \
    --model <model_id> \
    --dataset <dataset_id> \
    --space <space_id> \
    --bucket <bucket_id>

This source in Atlas

Scan everything a Hugging Face organization or user owns
trufflehog huggingface --org <orgname> --user <username>

This source in Atlas

Scan Hugging Face discussion and pull request comments
trufflehog huggingface --model <model_id> --include-discussions --include-prs

This source in Atlas

Scan piped input (stdin)
aws s3 cp s3://example/gzipped/data.gz - | gunzip -c | trufflehog stdin

This source in Atlas

Config files and custom detectors

  • A config file, passed with --config, can hold custom regex detectors and sources. Regex detectors work with any scan command; sources are only read by multi-scan.
  • Custom regex detectors need at least one regular expression and one keyword. To verify matches, TruffleHog posts them to a webhook you run; a 200 OK means verified.
  • The verify section is optional. Without it, matches are reported as unverified, which suits flagging generic passwords in config files.
  • Custom regex detectors are marked alpha and may change.
A config file with one GitHub source (README example)
sources:
- connection:
    '@type': type.googleapis.com/sources.GitHub
    repositories:
    - https://github.com/trufflesecurity/test_keys.git
    unauthenticated: {}
  name: example config scan
  type: SOURCE_TYPE_GITHUB
  verify: true

Further reading

  • Since v3.0, TruffleHog is released under the AGPL-3.0 license.