Scan and redact hardcoded credentials in source code
Project description
Credactor
TL;DR: Detect and redact hardcoded credentials before they hit version control. Regex + entropy + context-aware analysis, SARIF output, pre-commit hooks, parallel scanning, automated redaction.
Credactor scans source code for hardcoded secrets — API keys, tokens, passwords, private keys, connection strings — and replaces them with language-aware environment variable references before they reach version control. It runs as a CLI tool, a pre-commit hook, or in CI pipelines. SARIF output plugs straight into GitHub Code Scanning.
Why Credactor?
Most secret scanners stop at detection. Credactor redacts in place and replaces credentials with the right env var syntax for each language — os.environ in Python, process.env in JS, System.getenv in Java, and so on. It assigns severity levels so you can triage critical findings first instead of wading through noise.
Install
pip install credactor
From source:
git clone https://github.com/rxb06/Credactor.git
cd Credactor
pip install -e .
After either method, credactor works from any directory.
Quick Start
Always run
--dry-runfirst and review findings before redacting. False positives are possible — use# credactor:ignoreor.credactorignoreto suppress them.
# Scan current directory (dry run)
credactor --dry-run .
# Scan and interactively redact
credactor .
# Redact everything without prompting
credactor --fix-all .
# CI mode — exit 1 on findings
credactor --ci .
Pre-commit Hook
# .pre-commit-config.yaml
repos:
- repo: https://github.com/rxb06/Credactor
rev: v2.3.3
hooks:
- id: credactor
Or run as a module:
python -m credactor .
Detection
| Category | Examples | Severity |
|---|---|---|
| Cloud provider keys | AWS (AKIA...), GCP (AIza...), Stripe (sk_live_...), Slack (xoxb-...) |
Critical |
| Platform tokens | GitHub (ghp_, github_pat_), GitLab (glpat-), npm (npm_), PyPI (pypi-) |
Critical |
| Private keys | PEM blocks (-----BEGIN RSA PRIVATE KEY-----) |
Critical |
| JWT tokens | eyJ... three-segment tokens |
High |
| Connection strings | postgresql://user:pass@host, mongodb+srv://..., redis://... |
High |
| Variable assignments | password = "...", api_key = "...", db_password = "..." |
High/Medium |
| XML attributes | <add key="Password" value="..." /> |
High |
| High-entropy strings | Hex (32-64 chars), Base64 (60+ chars) | Medium/Low |
Features
- Entropy-based detection with per-pattern thresholds to cut false positives
- Interactive or batch redaction — review one-by-one, or
--fix-all - Language-aware replacements (
os.environ,process.env,System.getenv, etc.) - Git history scanning via
--scan-history .bakbackups before any file modification- Inline
# credactor:ignoresuppression and.credactorignoreallowlists - Per-repo config via
.credactor.toml - Parallel scanning (8 workers) for large repos
- SARIF 2.1.0 output with column-level annotations for GitHub Code Scanning
--fail-on-errorto catch files that couldn't be scanned
Scanned File Types
.py .js .ts .jsx .tsx .sh .bash .env .env.* .cfg .ini .toml .yaml .yml .rb .go .java .php .cs .kt .tf .hcl .conf .properties .xml
JSON files are excluded by default (high false-positive rate from API responses). Use --scan-json to include them.
Exit Codes
| Code | Meaning |
|---|---|
0 |
No findings, or all resolved |
1 |
Unresolved findings |
2 |
Error, or files skipped with --fail-on-error |
Docs
| Document | Description |
|---|---|
| Setup Guide | Installation, configuration, CI/CD integration |
| User Guide | CLI reference, replacement modes, backup safety |
| Examples | Common workflows with output |
| Integration | Pre-commit hooks, CI pipelines |
| Security | Threat model, hardening measures, known limitations |
| Changelog | Version history |
| Contributing | Development setup, code style, PR process |
| Disclaimer | Limitations, safe usage, warranty |
Licence
Apache 2.0. See LICENSE.
Project details
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 credactor-2.3.3.tar.gz.
File metadata
- Download URL: credactor-2.3.3.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e70636b02575923e2549753b8d0218b3b9cad12d95d826692f0650efe60bf87
|
|
| MD5 |
278d21a733a94c2d52a02a78f442d1e3
|
|
| BLAKE2b-256 |
83b160c6f09f61893f1a0faec026570b709f91cbb52a210a6194bbb447c4ef72
|
Provenance
The following attestation bundles were made for credactor-2.3.3.tar.gz:
Publisher:
publish.yml on rxb06/Credactor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
credactor-2.3.3.tar.gz -
Subject digest:
7e70636b02575923e2549753b8d0218b3b9cad12d95d826692f0650efe60bf87 - Sigstore transparency entry: 1262976688
- Sigstore integration time:
-
Permalink:
rxb06/Credactor@91b87ab8df6cda4e3abde5d2d7ca2768c9d9f7b3 -
Branch / Tag:
refs/tags/v2.3.3 - Owner: https://github.com/rxb06
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91b87ab8df6cda4e3abde5d2d7ca2768c9d9f7b3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file credactor-2.3.3-py3-none-any.whl.
File metadata
- Download URL: credactor-2.3.3-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a167290b9d5f9332b7d56012dbb8db0ba0f907bf94f656723c5234dfe5d8fd6
|
|
| MD5 |
4b7f51861acfd5fbd1599cb19622712c
|
|
| BLAKE2b-256 |
0fa8b7ef8f405553bb933bb5ca203d8c42d152c0e21991f7215f63add5a8bac4
|
Provenance
The following attestation bundles were made for credactor-2.3.3-py3-none-any.whl:
Publisher:
publish.yml on rxb06/Credactor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
credactor-2.3.3-py3-none-any.whl -
Subject digest:
4a167290b9d5f9332b7d56012dbb8db0ba0f907bf94f656723c5234dfe5d8fd6 - Sigstore transparency entry: 1262976752
- Sigstore integration time:
-
Permalink:
rxb06/Credactor@91b87ab8df6cda4e3abde5d2d7ca2768c9d9f7b3 -
Branch / Tag:
refs/tags/v2.3.3 - Owner: https://github.com/rxb06
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91b87ab8df6cda4e3abde5d2d7ca2768c9d9f7b3 -
Trigger Event:
release
-
Statement type: