Skip to content

TruffleHog Executor

Category: Source Code Analysis Script: trufflehog.py Integration: CLI Faraday Plugin: Raw JSON Website: trufflesecurity/trufflehog

Description

Runs a TruffleHog secrets scan and imports each detected secret into Faraday as a vulnerability. Secrets that TruffleHog verifies against the provider are marked as verified and get a higher severity.

Prerequisites

  • trufflehog (v3) installed and available in the agent's PATH (checked with trufflehog --version)
  • git, if you scan a repository by URL
  • Read access to the target, either as a local path or a Git repository
  • Internet access from the agent, if you want TruffleHog to verify the secrets it finds

Configuration

Environment Variables (Setup)

Variable Required Description
GIT_USERNAME No Username for cloning private repositories over HTTPS (default: oauth2)
GIT_TOKEN No Access token for cloning private repositories over HTTPS

Execution Arguments

Parameter Type Mandatory Description
TRUFFLEHOG_TARGET string No* What to scan, as expected by the selected mode (e.g., a directory for filesystem). When TRUFFLEHOG_GIT_URL is set, it is a subpath inside the cloned repository.
TRUFFLEHOG_MODE string No TruffleHog subcommand to run, such as filesystem or git (default: filesystem)
TRUFFLEHOG_ONLY_VERIFIED boolean No Set to true to report only verified secrets
TRUFFLEHOG_NO_UPDATE boolean No Skip TruffleHog's self-update check (default: true)
TRUFFLEHOG_GIT_URL url No* Git repository to clone and scan
TRUFFLEHOG_GIT_REF string No Branch or tag to clone (default: the repository's default branch)

* You must set TRUFFLEHOG_TARGET, TRUFFLEHOG_GIT_URL, or both.

YAML Configuration Example

executors:
  trufflehog:
    repo_executor: trufflehog.py
    max_size: 65536
    varenvs:
      GIT_USERNAME: "<git_username>"
      GIT_TOKEN: "<git_token>"
    params:
      TRUFFLEHOG_TARGET:
        mandatory: false
        type: string
        base: string
      TRUFFLEHOG_MODE:
        mandatory: false
        type: string
        base: string
      TRUFFLEHOG_ONLY_VERIFIED:
        mandatory: false
        type: boolean
        base: boolean
      TRUFFLEHOG_NO_UPDATE:
        mandatory: false
        type: boolean
        base: boolean
      TRUFFLEHOG_GIT_URL:
        mandatory: false
        type: url
        base: string
      TRUFFLEHOG_GIT_REF:
        mandatory: false
        type: string
        base: string

How It Works

  1. If TRUFFLEHOG_GIT_URL is set, makes a shallow clone of the repository (at TRUFFLEHOG_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates with GIT_USERNAME/GIT_TOKEN.
  2. Runs trufflehog <mode> <target> --json, adding --no-update and --only-verified when enabled
  3. Groups the findings by the file (or repository) where each secret was found
  4. Creates one vulnerability per finding:
    • Name: the detector name plus secret, with (verified) for verified secrets
    • Severity: high for verified secrets, medium otherwise
    • Description: the detector, the verification result, the first 6 characters of the secret and its location
  5. Deletes the temporary clone when the run ends

Notes

  • Each file with findings becomes a host whose name is the file path (or the repository, or the target when TruffleHog gives no location).
  • Only the first 6 characters of each secret are stored in Faraday.
  • With a Git URL, TruffleHog scans the cloned working tree. Use the default filesystem mode in that case.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor. Use TRUFFLEHOG_ONLY_VERIFIED to reduce noise.