credsweep

Credential / secret scanner for files, dirs, stdin, and git history

v1.2.2
Linux

Quick Start

Install via jcli (recommended)

jcli install credsweep

If you don't have jcli yet, install it first with curl -fsSL https://cli.johlem.net/tools/jcli/install.sh | bash.

Scan a codebase

credsweep --path ./src                          # walk a directory
credsweep --stdin < suspicious.log              # read from stdin
credsweep --git --path .                        # scan git history for secrets ever committed
credsweep --path . --output sarif > cs.sarif   # SARIF for GitHub Code Scanning
credsweep --install-hook --path .               # write a .git/hooks/pre-commit

What it does

credsweep is a credential / secret scanner — feed it a file tree, stdin, or a git repository's history and it returns every accidentally committed AWS key, GitHub PAT, private key, JWT, database connection string, and ~45 other things. Built in Rust, single binary. Absorbed the retired credaudit tool — its full 53-pattern catalogue plus its sensitivity filter, entropy validation, git-history scan, and false-positive filtering now live here.

CLI

FlagWhat it does
--path <PATH>Scan a file or directory tree (with skip list: .git, node_modules, target, …)
--stdinRead the input from stdin (mutually exclusive with --path)
--gitScan git history of the repo at --path (or CWD). Catches credentials introduced and later removed
--sensitivity {high,medium,low}Pattern subset (default medium)
-o, --output <FMT>terminal / json / csv / markdown / sarif
-O, --out-file <PATH>Write structured output to file
--install-hookWrite a .git/hooks/pre-commit at --path (or CWD)
--forceOverwrite an existing hook (use with --install-hook)
--baselineRecord current findings to the baseline file, exit 0
--updateFilter against an existing baseline — report only new findings
--baseline-file <PATH>Where to read/write the baseline (default .credsweep-baseline.json)
--allow-list <FILE>Path to a TOML allow-list — findings matching any rule are suppressed
-X, --exclude-path <GLOB>Skip paths matching GLOB (repeatable, relative to scan root). Examples: -X 'vendor/**', --exclude-path 'tests/fixtures/*.env'. Short-circuits the walker so excluded subtrees are never opened.
--max-file-size <MB>Skip files larger than N MB (default 5)
--follow-symlinksFollow symlinks during directory walk (default off — prevents loops)
--include-hiddenInclude dotfiles and dot-directories
--summaryAfter the scan, print a stderr block: totals, severity breakdown, top 5 patterns by hit count, files scanned/skipped. Stderr-only so it doesn't pollute structured-output pipelines.
-m, --minimalOne finding per line, pipe-friendly
-v, --verbosePer-file timings on stderr

Subcommand: credsweep patterns list

Show every embedded detection pattern with its severity, sensitivity, kind, and confidence. Useful for confirming what the scanner is looking for before committing to a sensitivity tier, or building per-team allow-lists from the catalogue.

credsweep patterns list                                # full catalogue (text)
credsweep patterns list --severity critical            # filter by severity
credsweep patterns list --sensitivity high --format md # markdown table
credsweep patterns list --format json | jq '.[].name'  # pipe to jq

Flags: --format {text,json,md}, --severity {info,low,medium,high,critical}, --sensitivity {high,medium,low}.

Allow-list TOML format

# All present matchers are ANDed.
# At least one of (file_glob, pattern, snippet) must be set.

[[allow]]
file_glob = "tests/**"
pattern   = "JWT Token"
note      = "test fixtures — checked manually"

[[allow]]
snippet = "AKIAJSIRBVE5YQQTESTX"
note    = "intentional fixture key in docs"

[[allow]]
pattern = "Generic Password Assignment"
note    = "this codebase's password=... lines are template variables"

CI workflow

Common pattern: baseline once, then update on every PR. Pre-existing leaks don't break CI; new ones do.

# One-time setup (committed alongside the codebase)
credsweep --path . --sensitivity medium --baseline
git add .credsweep-baseline.json
git commit -m "ci: credsweep baseline"

# CI step (.github/workflows/ci.yml etc.)
credsweep --path . --sensitivity medium --update --output sarif --out-file cs.sarif

Design choices

Not a silver bullet: credsweep catches credentials that match its 53 patterns plus value-scoped entropy heuristics. Custom organisational secret formats won't match — add them to data/patterns.toml (one TOML entry per pattern, no code changes needed). For supply-chain scenarios (CycloneDX/SPDX SBOMs containing credentials in dependency metadata) credsweep currently treats them as plain JSON — an SBOM-aware mode is on the backlog per the 2026-05-29 suite audit.