Redact secrets from agent output, logs, diffs, and CI — pipe-friendly CLI + GitHub Action
Project description
redactcli
Redact secrets from agent output, logs, diffs, and CI.
Pipe-friendly CLI + GitHub Action. No cloud. No API key. Designed for humans and coding agents.
pip install redactcli
# Pipe agent / CI logs
cat agent.log | redactcli
# Scan a tree; exit 1 if secrets found
redactcli scan src/ .env.example
# Rewrite a file in place
redactcli redact -i ./notes.md
Why
Agents and CI constantly echo:
- AWS keys
- GitHub / GitLab / npm / PyPI tokens
- Private keys
- Database URLs with passwords
- JWTs and Slack/Stripe keys
redactcli strips those before logs leave your machine or a PR is merged.
Install
pip install redactcli
# or one-shot
uvx redactcli --help
Requires Python 3.10+. Zero runtime dependencies.
CLI
redact (default)
Read stdin and/or files; write redacted text to stdout.
# stdin
echo 'token=ghp_…' | redactcli
echo 'token=ghp_…' | redactcli redact
# files
redactcli redact ./dump.txt
redactcli redact -i ./dump.txt # in place
redactcli redact ./a.log -o ./a.clean # to file
# JSON for agents
redactcli redact --json < dump.txt
scan
Report findings without rewriting. Exit code 1 if anything matched (CI-friendly).
redactcli scan .
redactcli scan --json src/
redactcli scan --no-fail-on-findings . # report only
patterns
List built-in rules.
redactcli patterns
redactcli patterns --json
Options
| Flag | Meaning |
|---|---|
--rules FILE |
Extra patterns (JSON) |
--include NAME |
Only these built-ins (repeatable) |
--exclude NAME |
Skip these built-ins (repeatable) |
--min-confidence high|medium |
Default medium |
--json |
Machine-readable output |
Built-in detections (high signal)
- PEM / OpenSSH private keys
- AWS access key ids (
AKIA…/ASIA…) - AWS secret keys near assignment keywords
- GitHub tokens (
ghp_,github_pat_, …) - GitLab (
glpat-), Slack, Stripe, OpenAI, Anthropic - PyPI / npm tokens
- JWTs
- DB / HTTP URLs with embedded credentials
- Common
api_key=/password=assignments - Google API keys, Azure AccountKey
Use redactcli patterns for the full list.
Custom rules
rules.json:
{
"patterns": [
{
"name": "acme_token",
"description": "Acme internal token",
"regex": "\\bACME_[A-Z0-9]{16}\\b",
"replacement": "[REDACTED:ACME_TOKEN]",
"confidence": "high"
}
]
}
redactcli scan --rules rules.json .
GitHub Action
# .github/workflows/secret-scan.yml
name: Secret scan
on:
pull_request:
push:
branches: [main]
jobs:
redactcli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: AshSgDe29071999/redactcli/action@v0.1.0
with:
paths: .
min-confidence: medium
fail-on-findings: true
Or pin to a commit SHA after release.
Action inputs
| Input | Default | Description |
|---|---|---|
paths |
. |
Paths to scan |
min-confidence |
medium |
high or medium |
fail-on-findings |
true |
Fail job on secrets |
python-version |
3.12 |
Runner Python |
version |
latest | Pin PyPI version |
Library use
from redactcli import redact_text, scan_text
result = redact_text(open("log.txt").read())
print(result.text)
print(result.count, "findings")
for f in scan_text("AKIAIOSFODNN7EXAMPLE"):
print(f.pattern, f.line, f.excerpt)
Agent / CLAUDE.md snippet
Before pasting logs or env dumps into chat or commits, run:
redactcli redact < file
# or
cmd 2>&1 | redactcli
Development
git clone https://github.com/AshSgDe29071999/redactcli.git
cd redactcli
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -q
ruff check src tests
Security notes
- Patterns aim for high precision; no tool catches everything.
- Prefer
--min-confidence highin noisy monorepos. - Rotate any secret that ever appeared unredacted in logs or chat.
- This package does not send data anywhere.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redactcli-0.1.0.tar.gz.
File metadata
- Download URL: redactcli-0.1.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b48feeac70886f165022db6fe504533a3d7c4423c8e199fcbcb4e2467606368a
|
|
| MD5 |
e6bae3104856fe685b033aa4fb5ba7fb
|
|
| BLAKE2b-256 |
6f1d0dcccc3b137e1a85db982a72c6c41a98013af7ad3cad5e21fe74450a94f8
|
File details
Details for the file redactcli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: redactcli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7831d18c322aaf561f7abc46fecd315482f0e64e4a763357354a31b0662e68e
|
|
| MD5 |
3516a1006d040628ca15bbc0b27acb71
|
|
| BLAKE2b-256 |
81c2357e23ccb75ded946b3c9fdd2e0d9e66f8dd6e7a4361ac938115776ea302
|