LinuxCommandLibrary

gitleaks

Detect secrets and sensitive data in Git repositories

TLDR

Scan repository

$ gitleaks detect
copy
Scan specific path
$ gitleaks detect --source [path]
copy
Scan and report
$ gitleaks detect --report-format json --report-path [report.json]
copy
Protect pre-commit
$ gitleaks protect
copy
Use custom config
$ gitleaks detect --config [.gitleaks.toml]
copy

SYNOPSIS

gitleaks command [options]

DESCRIPTION

gitleaks detects secrets and sensitive data in Git repositories. It scans commits for API keys, passwords, tokens, and other credentials that should not be in version control.
The tool uses regex patterns to identify common secret formats. It can scan entire commit history or be used as a pre-commit hook to prevent accidental secret commits.

PARAMETERS

detect

Scan for secrets.
protect
Pre-commit hook mode.
--source PATH
Repository path.
--report-format FORMAT
Output format (json, csv, sarif).
--report-path FILE
Output file path.
--config FILE
Configuration file.
--help
Display help information.

CONFIGURATION

.gitleaks.toml

Custom rules configuration file defining regex patterns, allowlists, and scanning behavior.

CAVEATS

False positives possible. Custom rules may be needed. History scanning can be slow.

HISTORY

gitleaks was created by Zachary Rice to address the security risk of secrets accidentally committed to git repositories.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community