Skip to content

Gitleaks Executor

Category: Source Code Analysis Script: gitleaks.py Integration: CLI Faraday Plugin: GitleaksPlugin Website: gitleaks/gitleaks

Description

Runs Gitleaks on a source code directory or Git repository to find hard-coded secrets (API keys, tokens, private keys) and imports the findings into Faraday.

Prerequisites

  • gitleaks installed and available in the agent's PATH (checked with gitleaks version)
  • git, if you scan a repository by URL
  • Read access to the source code, either as a local path or a Git repository

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
GITLEAKS_TARGET string No* Path to scan. When GITLEAKS_GIT_URL is set, it is a subpath inside the cloned repository (e.g., src/).
GITLEAKS_MODE string No Scan mode: dir (scan files, default), git (scan the commit history) or stdin
GITLEAKS_CONFIG string No Path to a custom Gitleaks config file (default: the built-in rules)
GITLEAKS_REDACT boolean No Set to true to mask the secret values in the results (default: false)
GITLEAKS_GIT_URL url No* Git repository to clone and scan
GITLEAKS_GIT_REF string No Branch or tag to clone (default: the repository's default branch)

* You must set GITLEAKS_TARGET, GITLEAKS_GIT_URL, or both.

YAML Configuration Example

executors:
  gitleaks:
    repo_executor: gitleaks.py
    max_size: 65536
    varenvs:
      GIT_USERNAME: "<git_username>"
      GIT_TOKEN: "<git_token>"
    params:
      GITLEAKS_TARGET:
        mandatory: false
        type: string
        base: string
      GITLEAKS_MODE:
        mandatory: false
        type: string
        base: string
      GITLEAKS_CONFIG:
        mandatory: false
        type: string
        base: string
      GITLEAKS_REDACT:
        mandatory: false
        type: boolean
        base: boolean
      GITLEAKS_GIT_URL:
        mandatory: false
        type: url
        base: string
      GITLEAKS_GIT_REF:
        mandatory: false
        type: string
        base: string

How It Works

  1. If GITLEAKS_GIT_URL is set, makes a shallow clone of the repository (at GITLEAKS_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates with GIT_USERNAME/GIT_TOKEN.
  2. Runs gitleaks <mode> on the target, with a JSON report
  3. Parses the report with GitleaksPlugin and sends the results to Faraday
  4. Deletes the temporary clone when the run ends

Notes

  • Set GITLEAKS_TARGET, GITLEAKS_GIT_URL, or both. GITLEAKS_TARGET must point inside the cloned repository when both are set; paths that escape it (e.g., ../) are rejected.
  • In git mode Gitleaks scans the whole commit history of the repository. A shallow clone only contains the latest commit, so use a local path to scan the full history.
  • A scan with no findings is valid and imports nothing.
  • The token is hidden in the agent log if the clone fails.
  • Supports the shared agent parameters (AGENT_CONFIG_* tags and severity filters).