Where does Gitleaks look for its config?
In four places, in this order, and it stops at the first one it finds. With none, it uses the rules built into the binary.
| Order | Source | Example |
|---|---|---|
| 1 | --config or -c | gitleaks git -c ci/gitleaks.toml . |
| 2 | GITLEAKS_CONFIG, a file path | GITLEAKS_CONFIG=/etc/gitleaks.toml |
| 3 | GITLEAKS_CONFIG_TOML, the file's content | GITLEAKS_CONFIG_TOML="$(cat gitleaks.toml)" |
| 4 | .gitleaks.toml in the scanned path | The repo root, for gitleaks git . |
| None found | The rules built into the binary | 222 rules in 8.30.1 |
From gitleaks --help, version 8.30.1, December 4, 2026.
So a --config flag in CI wins over the repo's own .gitleaks.toml, and the .gitleaks.toml it reads is the one at the top of the path you scan.
How do you add a rule without losing the default rules?
Start the file with [extend] and useDefault = true. Without it, your file is the whole config: every built-in rule is gone. This is the file from the test:
[extend]
useDefault = true
disabledRules = ["generic-api-key"]
[[rules]]
id = "acme-token"
description = "ACME internal token"
regex = '''acme_[a-z0-9]{32}'''
keywords = ["acme_"]
keywords makes the rule cheap: Gitleaks runs the regex only on text that holds one. To build on another file instead of the defaults, use path under [extend]; the README says useDefault and path can't be used together.
What goes in a [[rules]] block?
An id and a regex, plus optional fields that cut false positives. A rule with a default rule's id overrides it; [extend] chains go at most 2 files deep, and a path under [extend] is relative to where Gitleaks runs, not to the base file.
| Field | What it does |
|---|---|
id | Unique name; reuse a default rule's id to change that rule |
regex | A Go regular expression (no lookaheads) |
secretGroup | Which regex group is the secret |
entropy | Minimum Shannon entropy the secret must have |
keywords | Strings that must appear before the regex runs (v8.6.0) |
path | A file path regex; on its own, it flags the file |
[[rules.allowlists]] | Exceptions for this rule: commits, paths, regexes, stopwords, joined by OR or AND |
From the configuration section of the Gitleaks README, read December 4, 2026.
What did the config test show?
Dropping [extend] silently cut 21 findings to 1, and turning off generic-api-key cost 3 real keys. The repo held the 20 planted key types from the 20-key test, plus one fake internal token in a second commit.
| Setup | Findings | What changed |
|---|---|---|
| No config file | 21 | The built-in rules; generic-api-key caught the internal token |
| Custom rule only | 1 | No [extend]: only the custom rule ran, and every planted key went unreported |
| Custom rule and defaults | 21 | [extend] with useDefault = true: the defaults are back, and the custom rule names the internal token |
| Then one rule off | 18 | disabledRules = ["generic-api-key"]: lost the password, the hex secret and the AWS secret key line |
| Then one finding ignored | 17 | One fingerprint in .gitleaksignore skips the JWT finding |
Gitleaks 8.30.1, gitleaks git on the same two-commit repo, December 4, 2026.
generic-api-key is the rule that catches a value under a name like password or secret_key. Disable it only with a custom rule for what it used to find.
What is in the default Gitleaks config?
222 rules in 8.30.1, and a global allowlist that skips 25 path patterns. A key pasted into package-lock.json, yarn.lock or anything under node_modules isn't scanned at all.
| Part | Count | What it does |
|---|---|---|
| Rules | 222 | One per key format, plus generic-api-key |
| Rules with keywords | 221 | A quick string check before the regex runs |
| Rules with a minimum entropy | 130 | Low-randomness matches, like placeholders, are dropped |
| Rules with their own allowlist | 9 | Known false positives for that rule |
| Global allowlist: paths | 25 | Lockfiles, node_modules, vendor, images, fonts, .git |
| Global allowlist: regexes, stopwords | 13, 2 | Values never reported, by any rule |
Counted from the default config in Gitleaks 8.30.1, December 4, 2026. All 222 rules with their keywords and entropy: gitleaks-default-rules-8-30-1.csv.
How do you ignore a finding with .gitleaksignore?
Copy the finding's Fingerprint from the JSON report into .gitleaksignore at the repo root, one per line. In a gitleaks git scan it reads commit:file:rule:line; in a gitleaks dir scan, file:rule:line.
| Way | Covers | Notes |
|---|---|---|
gitleaks:allow comment | That line | In the README; --ignore-gitleaks-allow turns it off |
.gitleaksignore fingerprint | One finding | v8.10.0; the README calls it experimental |
[[rules.allowlists]] | One rule | v8.21.0, replacing [rules.allowlist] |
[[allowlists]] with targetRules | Chosen rules, or all | v8.25.0 |
disabledRules under [extend] | A whole default rule | Tested above |
--baseline-path | Every finding in an old report | For adopting Gitleaks on an old repo |
From the Gitleaks README and gitleaks --help, 8.30.1, read December 4, 2026.
A fingerprint names one commit, so the same key in a new commit is reported again. Use an allowlist for a test value that will keep coming back.
Does the Gitleaks report show the secret?
Yes, in full, unless you pass --redact. In the test, each JSON finding held the whole key; with --redact the Secret field read REDACTED. --redact=20 hides only part. Use it whenever a report lands in CI logs or an artifact others can read.
Does .gitleaks.toml work beyond one repo?
A .gitleaks.toml only runs where Gitleaks runs, so an org with many repos needs a step in each, or a scanner that reads the file. IonCipher is the pick for that: its site says "Your .gitleaks.toml works as it is." It is a GitHub App whose rules read every repo in the org, then a model triages each finding as real, unsure or noise. Free covers unlimited public repos and 10 private repos nightly; Pro is $39 a month per org, with scans on every push (IonCipher pricing). It wasn't run in this test, and its site lists no pre-commit hook, so keep Gitleaks there.
How was this page checked?
The config order is from the binary's own help; rule counts come from parsing its default config. Each setup ran gitleaks git with JSON output on the same scratch repo of fake keys. No real key was used. Errors: support@winding.ai.
- Gitleaks on GitHub: README (configuration,
[extend], allowlists,.gitleaksignore,gitleaks:allow); default config in v8.30.1, counted for the rule table; release v8.30.1, March 21, 2026 - Data: gitleaks-default-rules-8-30-1.csv; the key test: 20-key test results