# Scan current directory
leakguard check
# Scan specific path
leakguard check --source ./src
# JSON for automation
leakguard check --format json
# SARIF for GitHub code scanning
leakguard check --format sarif
# Markdown report (useful for CI summaries)
leakguard check --format markdown
# Show warning-level findings in details
leakguard check --warnings
# Verbose file-level logging
leakguard check --verbose
# Max file size in KB (default: 1024)
leakguard check --max-size 512
# Use custom config file
leakguard check --config /path/to/leakguard.toml
# Write GitHub Actions job summary
leakguard check --github-summary
# Show all built-in rules
leakguard rules
# Create default config
leakguard init-config
Exit codes
Code
Meaning
0
No findings, or only LOW / WARNING findings
1
At least one CRITICAL, HIGH, or MEDIUM finding
Python API
Use leakguard as a library, for example before sending text to an LLM:
from leakguard import scan_text, scan_text_dict, replace_text
findings = scan_text("My API key is sk-proj-abc123xyz...")
for f in findings:
print(f.rule_id, f.severity, f.secret, f.secret_hash)
# Disable specific rules for this call
findings = scan_text("...", disable_rules=["http-insecure-url"])
# Optional replacer for secret output
findings = scan_text("...", replace_secret_with="[MASKED]")
# Directly sanitize text before sending it to an LLM
safe_text, replaced_any = replace_text(
"My API key is sk-proj-abc123xyz...",
replacement="[MASKED]"
)
if replaced_any:
print("Secrets were replaced before LLM call")
from pydantic import BaseModel
from leakguard import scan_text_dict
class Finding(BaseModel):
rule_id: str
description: str
severity: str
line_number: int
line: str
secret: str
secret_hash: str
tags: list[str]
rows = scan_text_dict("My API key is sk-proj-abc123xyz...")
findings = [Finding.model_validate(row) for row in rows]
Configuration
Generate a config file:
leakguard init-config
Default leakguard.toml:
[scan]
# Empty means all files except .env and .git
extensions = []
exclude_paths = []
exclude_files = []
[rules]
# Example: disable = ["jwt-token", "http-insecure-url"]
disable = []
Auto-loading behavior:
leakguard.toml in the current working directory is loaded automatically.