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¶
gitleaksinstalled and available in the agent'sPATH(checked withgitleaks 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¶
- If
GITLEAKS_GIT_URLis set, makes a shallow clone of the repository (atGITLEAKS_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates withGIT_USERNAME/GIT_TOKEN. - Runs
gitleaks <mode>on the target, with a JSON report - Parses the report with
GitleaksPluginand sends the results to Faraday - Deletes the temporary clone when the run ends
Notes¶
- Set
GITLEAKS_TARGET,GITLEAKS_GIT_URL, or both.GITLEAKS_TARGETmust point inside the cloned repository when both are set; paths that escape it (e.g.,../) are rejected. - In
gitmode 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).