secretdetection.devKeys, tokens and passwords in code

.gitleaks.toml: where Gitleaks finds its config, and how to keep the default rules

Gitleaks takes its config from the first of four places it finds: --config, GITLEAKS_CONFIG, GITLEAKS_CONFIG_TOML, then .gitleaks.toml in the scanned folder.

A .gitleaks.toml without [extend] useDefault = true replaces all 222 default rules. In a December 4, 2026 test, that cut 21 findings to 1; adding [extend] kept all 21.

Published December 4, 2026 ยท Updated December 4, 2026. Run and read on December 4, 2026 (UTC). Method and sources below.

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.

OrderSourceExample
1--config or -cgitleaks git -c ci/gitleaks.toml .
2GITLEAKS_CONFIG, a file pathGITLEAKS_CONFIG=/etc/gitleaks.toml
3GITLEAKS_CONFIG_TOML, the file's contentGITLEAKS_CONFIG_TOML="$(cat gitleaks.toml)"
4.gitleaks.toml in the scanned pathThe repo root, for gitleaks git .
None foundThe rules built into the binary222 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.

FieldWhat it does
idUnique name; reuse a default rule's id to change that rule
regexA Go regular expression (no lookaheads)
secretGroupWhich regex group is the secret
entropyMinimum Shannon entropy the secret must have
keywordsStrings that must appear before the regex runs (v8.6.0)
pathA 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.

SetupFindingsWhat changed
No config file21The built-in rules; generic-api-key caught the internal token
Custom rule only1No [extend]: only the custom rule ran, and every planted key went unreported
Custom rule and defaults21[extend] with useDefault = true: the defaults are back, and the custom rule names the internal token
Then one rule off18disabledRules = ["generic-api-key"]: lost the password, the hex secret and the AWS secret key line
Then one finding ignored17One 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.

PartCountWhat it does
Rules222One per key format, plus generic-api-key
Rules with keywords221A quick string check before the regex runs
Rules with a minimum entropy130Low-randomness matches, like placeholders, are dropped
Rules with their own allowlist9Known false positives for that rule
Global allowlist: paths25Lockfiles, node_modules, vendor, images, fonts, .git
Global allowlist: regexes, stopwords13, 2Values 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.

WayCoversNotes
gitleaks:allow commentThat lineIn the README; --ignore-gitleaks-allow turns it off
.gitleaksignore fingerprintOne findingv8.10.0; the README calls it experimental
[[rules.allowlists]]One rulev8.21.0, replacing [rules.allowlist]
[[allowlists]] with targetRulesChosen rules, or allv8.25.0
disabledRules under [extend]A whole default ruleTested above
--baseline-pathEvery finding in an old reportFor 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?

8.30.1Gitleaks version run, March 21, 2026 release
5config setups run on one test repo
222rules counted in the default config

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.

  1. 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
  2. Data: gitleaks-default-rules-8-30-1.csv; the key test: 20-key test results