f55569356fa3c6c6f386251d2c98a9fb101d3849
🔍 Gitleaks Pre-commit Hook
This custom pre-commit hook runs Gitleaks to generate reports in HTML (using customizable templates) or JSON, with optional rules.
🚀 Usage
Add this repo to your .pre-commit-config.yaml:
- repo: https://git.fridu.us/heckyel/gitleaks-pre-commit-hook
rev: v1.0.0
hooks:
- id: gitleaks-template-report
# Basic usage (default gitleaks rules)
args: ["--format=html"]
# With internal rules from this repo
# args: ["--format=html", "--rules-internal"]
# With external rules
# args: ["--format=html", "--rules-external", "--config=path/to/gitleaks.toml"]
⚠️ When using
--format=json, the--templateoption is ignored.
🧩 Available parameters
| Parameter | Description |
|---|---|
--template=NAME |
Choose the HTML report template (default: leet) |
--format=html|json |
Output format (html by default, or json) |
--redact |
Redacts detected secrets (replaces them with ***) in reports |
--force |
Forces the reinstallation of Gitleaks (useful for debugging or broken versions) |
--version=VERSION |
Specifies the version of Gitleaks to install (default: v8.27.0) |
--rules-internal |
Uses the internal rules file (rules/gitleaks.toml) |
--rules-external |
Requires --config to specify an external rules file |
--config=FILE |
Path to custom rules file (requires --rules-external) |
Rules Behavior:
- By default: Uses gitleaks' built-in rules only
- With
--rules-internal: Uses the internal rules file - With
--rules-external --config=FILE: Uses the specified external rules file
🎨 Available HTML templates (--format=html)
| Template name | Output file |
|---|---|
leet |
.pre-commit/gitleaks/report/index.html |
basic |
.pre-commit/gitleaks/report/index.html |
myspace |
.pre-commit/gitleaks/report/index.html |
w98 |
.pre-commit/gitleaks/report/index.html |
wxp |
.pre-commit/gitleaks/report/index.html |
⚠️ The output file is always named
index.htmlregardless of the selected template.
📂 Output files
HTML format:
.pre-commit/gitleaks/report/
├── index.html
JSON format:
.pre-commit/gitleaks/report/
├── report.json
✅ Requirements
gitleaksmust be installed and available in yourPATH- The rules file must exist if specified via
--configwith--rules-external
🛠️ Dev setup
pre-commit install
pre-commit run --all-files
📝 License
Description
Languages
Python
100%