gitleaks is a free, open source orchestration & scheduling project written in Go and released under MIT. It has 29,364 GitHub stars, 2,236 forks and 481 open issues, and was last pushed 9 days ago. On this registry it ranks #4 of 64 tracked projects in Orchestration & Scheduling, with 5 head-to-head comparisons available. It gained 37 stars over the last 3 tracked days.

What is gitleaks?

Gitleaks is an MIT-licensed, Go-based command-line tool that detects hardcoded secrets such as passwords, API keys, and tokens in git repositories, files, and standard input, and it serves developers and security teams that need to keep credentials out of source control.

What it is

Gitleaks lives in the git and CI/CD ecosystem, and its topic list places it squarely in DevSecOps and data-loss-prevention (DLP) practice. The project is written in Go and released under the MIT licence, distributed as a command-line tool that runs against git repositories, individual files, or anything piped to it through standard input. It is a scanner rather than a platform: it takes a source, applies its detection rules, and reports what it finds. The published homepage is gitleaks.io, and the tool ships as binaries for many popular platforms as well as through package managers and container registries.

The concrete problem it solves is credentials that get committed to a repository before anyone notices. Gitleaks takes the place of manual, after-the-fact review of commits and files by automating the search and surfacing matches with enough context to act on them. A finding reports the RuleID, an Entropy score, the File, the Line, the Commit, the Author, the Email, the Date, and a Fingerprint, so a reviewer can locate the exact line and commit and rotate the exposed value. The detection engine is regex-based, described by the project as "Regex is (almost) all you need," and it works the same way whether the input is a full git history or a stream of bytes.

Key capabilities

  • Scans git repositories, files, and standard input through a single command such as gitleaks git -v.
  • Applies a regex-based detection engine and reports each match with RuleID, Entropy, File, Line, Commit, Author, Email, Date, and Fingerprint.
  • Runs as a pre-commit hook declared in .pre-commit-config.yaml, with the hook id gitleaks pinned to a release such as v8.24.2, or the gitleaks-docker id for container execution.
  • Integrates with GitHub through the separate gitleaks-action.
  • Publishes official container images as zricethezav/gitleaks:latest on Docker Hub and ghcr.io/gitleaks/gitleaks:latest on ghcr.io.
  • Installs through Homebrew with brew install gitleaks, through Docker, or from source with the Go module github.com/gitleaks/gitleaks/v8 and make build.
  • Allows a deliberate bypass of the hook by prepending SKIP=gitleaks to a commit command.

Who uses it and how

  • Security and platform engineers embed it in CI/CD pipelines so that every change is scanned before it merges.
  • Individual developers run it as a pre-commit hook on their own machines, catching a secret at commit time rather than during review.
  • Teams on GitHub use gitleaks-action to scan pull requests without maintaining their own invocation.
  • Organisations treating secrets exposure as a DLP concern use the CLI against repositories or piped input as a repeatable check.

Getting started

Install through Homebrew with brew install gitleaks, pull the official image with docker pull zricethezav/gitleaks:latest or ghcr.io/gitleaks/gitleaks:latest, or build from source after cloning the repository and running make build. The same tool can then be wired in as a pre-commit hook or as a GitHub Action.

How it compares

No list of paid products appears in the available facts, so the only named neighbour is Betterleaks, the project the maintainer says he is shifting focus to. Gitleaks remains the established, widely-forked implementation, while future development energy is directed at its successor.

When to use it β€” and when not to

Gitleaks is feature complete, and the maintainer states that no new features will be merged; future releases will be security patches only. Teams that want active feature development, rather than a stable and frozen scanner, should look at Betterleaks instead. The project also carries a large backlog of open issues, so adopters should expect a mature but deliberately static tool.

project readme (upstream, from github) β€” read inline

Gitleaks

β”Œβ”€β—‹β”€β”€β”€β”
β”‚ β”‚β•²  β”‚
β”‚ β”‚ β—‹ β”‚
β”‚ β—‹ β–‘ β”‚
β””β”€β–‘β”€β”€β”€β”˜

[!WARNING] Gitleaks is feature complete. I'm not merging new features into Gitleaks. Future releases will be security patches only. I'm shifting my focus to Betterleaks

GitHub Action Test Docker Hub Gitleaks Action GoDoc GoReportCard License

Gitleaks is a tool for detecting secrets like passwords, API keys, and tokens in git repos, files, and whatever else you wanna throw at it via stdin. If you wanna learn more about how the detection engine works check out this blog: Regex is (almost) all you need.

➜  ~/code(master) gitleaks git -v

    β—‹
    β”‚β•²
    β”‚ β—‹
    β—‹ β–‘
    β–‘    gitleaks


Finding:     "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef",
Secret:      cafebabe:deadbeef
RuleID:      sidekiq-secret
Entropy:     2.609850
File:        cmd/generate/config/rules/sidekiq.go
Line:        23
Commit:      cd5226711335c68be1e720b318b7bc3135a30eb2
Author:      John
Email:       [email protected]
Date:        2022-08-03T12:31:40Z
Fingerprint: cd5226711335c68be1e720b318b7bc3135a30eb2:cmd/generate/config/rules/sidekiq.go:sidekiq-secret:23

Getting Started

Gitleaks can be installed using Homebrew, Docker, or Go. Gitleaks is also available in binary form for many popular platforms and OS types on the releases page. In addition, Gitleaks can be implemented as a pre-commit hook directly in your repo or as a GitHub action using Gitleaks-Action.

Installing

# MacOS
brew install gitleaks

# Docker (DockerHub)
docker pull zricethezav/gitleaks:latest
docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] [OPTIONS] [SOURCE_PATH]

# Docker (ghcr.io)
docker pull ghcr.io/gitleaks/gitleaks:latest
docker run -v ${path_to_host_folder_to_scan}:/path ghcr.io/gitleaks/gitleaks:latest [COMMAND] [OPTIONS] [SOURCE_PATH]

# From Source (make sure `go` is installed)
git clone https://github.com/gitleaks/gitleaks.git
cd gitleaks
make build

Pre-Commit

  1. Install pre-commit from https://pre-commit.com/#install

  2. Create a .pre-commit-config.yaml file at the root of your repository with the following content:

    repos:
      - repo: https://github.com/gitleaks/gitleaks
        rev: v8.24.2
        hooks:
          - id: gitleaks
    

    for a native execution of gitleaks or use the gitleaks-docker pre-commit ID for executing gitleaks using the official Docker images

  3. Auto-update the config to the latest repos' versions by executing pre-commit autoupdate

  4. Install with pre-commit install

  5. Now you're all set!

➜ git commit -m "this commit contains a secret"
Detect hardcoded secrets.................................................Failed

Note: to disable the gitleaks pre-commit hook you can prepend SKIP=gitleaks to the commit command and it will skip running gitleaks

➜ SKIP=gitleaks git commit -m "skip gitleaks check"
Detect hardcoded secrets................................................Skipped

Usage

Gitleaks scans code, past or present, for secrets

Usage:
  gitleaks [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  dir         scan directories or files for secrets
  git         scan git repositories for secrets
  help        Help about any command
  stdin       detect secrets from stdin
  version     display gitleaks version

Flags:
  -b, --baseline-path string          path to baseline with issues that can be ignored
  -c, --config string                 config file path
                                      order of precedence:
                                      1. --config/-c
                                      2. env var GITLEAKS_CONFIG
                                      3. env var GITLEAKS_CONFIG_TOML with the file content
                                      4. (target path)/.gitleaks.toml
                                      If none of the four options are used, then gitleaks will use the default config
      --diagnostics string            enable diagnostics (http OR comma-separated list: cpu,mem,trace). cpu=CPU prof, mem=memory prof, trace=exec tracing, http=serve via net/http/pprof
      --diagnostics-dir string        directory to store diagnostics output files when not using http mode (defaults to current directory)
      --enable-rule strings           only enable specific rules by id
      --exit-code int                 exit code when leaks have been encountered (default 1)
  -i, --gitleaks-ignore-path string   path to .gitleaksignore file or folder containing one (default ".")
  -h, --help                          help for gitleaks
      --ignore-gitleaks-allow         ignore gitleaks:allow comments
  -l, --log-level string              log level (trace, debug, info, warn, error, fatal) (default "info")
      --max-archive-depth int         allow scanning into nested archives up to this depth (default "0", no archive traversal is done)
      --max-decode-depth int          allow recursive decoding up to this depth (default "0", no decoding is done)
      --max-target-megabytes int      files larger than this will be skipped
      --no-banner                     suppress banner
      --no-color                      turn off color for verbose output
      --redact uint[=100]             redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)
  -f, --report-format string          output format (json, csv, junit, sarif, template)
  -r, --report-path string            report file
      --report-template string        template file used to generate the report (implies --report-format=template)
      --timeout int                   set a timeout for gitleaks commands in seconds (default "0", no timeout is set)
  -v, --verbose                       show verbose output from scan
      --version                       version for gitleaks

Use "gitleaks [command] --help" for more information about a command.

Commands

⚠️ v8.19.0 introduced a change that deprecated detect and protect. Those commands are still available but are hidden in the --help menu. Take a look at this gist for easy command translations. If you find v8.19.0 broke an existing command (detect/protect), please open an issue.

There are three scanning modes: git, dir, and stdin.

Git

The git command lets you scan local git repos. Under the hood, gitleaks uses the git log -p command to scan patches. You can configure the behavior of git log -p with the log-opts option. For example, if you wanted to run gitleaks on a range of commits you could use the following command: gitleaks git -v --log-opts="--all commitA..commitB" path_to_repo. See the git log documentation for more information. If there is no target specified as a positional argument, then gitleaks will attempt to scan the current working directory as a git repo.

Dir

The dir (aliases include files, directory) command lets you scan directories and files. Example: gitleaks dir -v path_to_directory_or_file. If there is no target specified as a positional argument, then gitleaks will scan the current working directory.

Stdin

You can also stream data to gitleaks with the stdin command. Example: cat some_file | gitleaks -v stdin

Creating a baseline

When scanning large repositories or repositories with a long history, it

readme truncated β€” read the full docs on github

Frequently asked questions

Is gitleaks free to use?

gitleaks is open source under the MIT licence. There is no licence fee and no seat count β€” you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does gitleaks do?

Find secrets with Gitleaks πŸ”‘

What is gitleaks written in?

gitleaks is primarily written in Go. Its source is publicly available at https://github.com/gitleaks/gitleaks, and it has 29,364 GitHub stars.