gitleaks/gitleaks
How to contribute
The canonical contribution guide is CONTRIBUTING.md. This page summarizes the workflow and links to deeper guides for testing, debugging, and conventions.
Pickup process
- Look for an open issue describing the change. If none exists, open one first and comment that you're working on it.
- Link your PR to the issue. Fill out the PR template (
.github/PULL_REQUEST_TEMPLATE.md). - Make sure tests pass. The CI matrix runs on Ubuntu and Windows with Go 1.25 (
.github/workflows/test.yml).
Definition of done
A PR is ready for merge when:
go build ./...succeeds on all platforms (Ubuntu and Windows are gated).go test ./...passes (CI usesgotestsum --raw-command -- go test -json ./... --race).- For changes to rules:
go generate ./...produces no diff againstconfig/gitleaks.toml. The CI stepValidate Configenforces this. golangci-lint runis clean (lints configured in.golangci.yaml). Locally:make lint.- The change is reviewed by a maintainer and any feedback addressed.
Adding a new rule
This is the most common contribution. The full walk-through is in CONTRIBUTING.md, but the steps in brief:
- Create
cmd/generate/config/rules/{provider}.godefining a function that returns*config.Rule. UseGenerateSemiGenericRegex(when an identifier keyword is required) orGenerateUniqueTokenRegex(when the prefix is unique enough to stand alone). Both are defined incmd/generate/config/utils/generate.go. - Provide true positive (
tps) and false positive (fps) samples. Thevalidate(r, tps, fps)helper checks them at config-generation time, so a misconfigured rule fails themake buildstep rather than slipping through. - Add
rules.YourProvider(),to theconfigRulesslice incmd/generate/config/main.go, keeping it alphabetical. - Run
make config/gitleaks.toml(or justmake build) to regenerate the embedded default config. - Spot-check the new rule in the generated
config/gitleaks.toml. - Open a PR.
The repo has 131 rule files at the moment, contributing 222 compiled rules — a single .go file often produces multiple variants (e.g., aws.go produces several AWS rule shapes).
Sub-pages
- Development workflow — branch, code, test, PR, merge cycle
- Testing — what gets tested where, how to run
- Debugging — logs, profiling, common pitfalls
- Patterns and conventions — the unwritten rules
- Tooling — Makefile, golangci-lint, goreleaser
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.