Skip to main content

PyPI CI License

Credactor

Find the secret. Fix it. Commit clean.

Secret scanners are good at sounding the alarm and not much help putting it out. They hand you a list of leaked credentials and leave the cleanup to you. Credactor closes the loop: it finds a hardcoded secret and rewrites it in place, so a leak goes from detection to fix in a single command.

Credactor: scan, redact, commit clean Keeping credentials out of source code is a baseline security practice, not an optional one. Credactor makes that baseline cheap to hold, on your machine before a commit or in CI before a merge. Run it on its own, or alongside the scanners you already trust.
# Credactor finds this:
db_password = "h8Tq2vKp9mRz4Wd"

# By default it rewrites the secret as a sentinel that fails loudly at runtime:
db_password = "REDACTED_BY_CREDACTOR"

# With --replace-with env, it writes a reference that reads from the environment:
db_password = os.environ["DB_PASSWORD"]

Redaction rewrites files in your working tree. If a secret has already been committed, rotate the key and scrub history as well (for example, with git filter-repo). Rewriting a file is not a substitute for revoking a leaked credential.


Why Credactor

  • Redaction, not just detection. Most scanners stop at the finding. Credactor replaces the secret in place: a loud REDACTED_BY_CREDACTOR sentinel that fails at runtime by default, or a language-aware environment-variable reference (Python, JavaScript/TypeScript, Go, Java/Kotlin, Ruby, PHP, and shell) such as os.environ["KEY"]. The replacement is valid code. If the file does not already include the matching import (for example import os), add it.
  • Safe by default. Atomic writes, automatic .bak backups, symlink-boundary and file-permission guards, and full-secret masking in every output. If a safe backup cannot be written, Credactor skips the file rather than rewrite it blind, and a crash mid-write leaves the original intact.
  • Zero runtime dependencies. Pure Python 3.11+ standard library, plus an optional extra for non-UTF-8 encodings.
  • Built for the pipeline. SARIF output for GitHub Code Scanning, a read-only --ci gate with precise exit codes, a pre-commit hook (beta), and ingestion of Gitleaks, TruffleHog or Betterleaks reports. Detect with the scanner you already run, remediate with Credactor.

Install

pip install credactor

Requires Python 3.11+. No other dependencies. Runs on Linux, macOS, and Windows (CI-tested on Linux and Windows).

From source:

git clone https://github.com/rxb06/credactor.git
cd credactor
pip install -e .

credactor then works from any directory.

Quick start

Run --dry-run first and review the findings before redacting. False positives are possible, and under --fix-all a false positive gets rewritten. Suppress known-safe values with # credactor:ignore or a .credactorignore entry.

credactor --dry-run .                 # scan, change nothing
credactor .                           # scan, then redact interactively (y/n per finding)
credactor --fix-all .                 # redact everything after one confirmation
credactor --fix-all --yes .           # redact non-interactively (CI / scripts)
credactor --ci .                      # read-only gate: exit 1 on findings
credactor --replace-with env .        # redact to env-var references instead of the sentinel

Pre-commit hook (beta)

Hook integration is in beta. Run credactor --dry-run . manually before relying on it alone.

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/rxb06/credactor
    rev: v2.7.2   # pin to the latest release tag
    hooks:
      - id: credactor

Detection

Credactor detects the credential types that leak most often, and assigns each a severity so you can triage at a glance.

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 … PRIVATE KEY-----) Critical
JWTs eyJ… three-segment tokens High
Connection strings URLs with inline credentials (scheme://user:pass@host) High
Credential variables password = "…", api_key = "…", secret_key = "…" High/Medium/Low
XML attributes <add key="Password" value="…" /> High/Medium/Low
High-entropy strings quoted hex (32–64 chars) / Base64 (60+ chars) Medium/Low

Deterministic provider tokens (the prefixes above) are flagged regardless of entropy. Heuristic detectors (JWTs, connection strings, hex, Base64) must clear an entropy floor. Standalone hex or Base64 is flagged only when quoted. An unquoted high-entropy value is caught only on a credential-named variable, which spares git SHAs and checksums. For the full detection and severity rules, see the Manual.

Credactor's native rule set is narrower than a dedicated scanner's, and some provider formats (for example SendGrid, Twilio, and Slack webhooks) are not detected. Its edge is remediation: pair it with Gitleaks, TruffleHog or Betterleaks for the broadest detection, or run it on its own.

Pair it with another scanner, redact the lot

Credactor stands on its own, and it gets stronger in company. Already run Gitleaks, TruffleHog or Betterleaks? Pass their report to Credactor and it redacts the combined set, deduplicated against its own findings (on overlap, the higher severity wins). One remediation pass covers your scan and theirs:

gitleaks dir . -f json -r gitleaks.json
credactor --from-gitleaks gitleaks.json --fix-all --yes .

betterleaks dir . -f json -r betterleaks.json
credactor --from-betterleaks betterleaks.json --fix-all --yes .

--from-gitleaks / --from-trufflehog / --from-betterleaks (or an [ingest] table in .credactor.toml) require a directory target — point Credactor at the same root the scanner ran against. Report paths resolve against the working directory, and a report is a snapshot: regenerate it after redacting or changing the tree. See the CI Integration guide.

More features

  • Interactive or batch redaction; a custom replacement string via --replacement; --scan-history to scan git commit history
  • Secure backups: --secure-delete (overwrite and remove the .bak; raises the bar against casual recovery, not a forensic guarantee) or --secure-backup-dir to store backups outside the repo
  • Inline # credactor:ignore and .credactorignore allowlists (globs, file:line, value literals)
  • Per-repo config via .credactor.toml
  • 29 source/config/notes file types out of the box (.txt included); --scan-json to include JSON; --fail-on-error to fail when a file cannot be read

Scanned file types

.py .js .ts .jsx .tsx .sh .bash .env .cfg .ini .toml .yaml .yml .rb .go .java .php .cs .kt .tf .hcl .conf .config .properties .xml .pem .key .crt .txt

Plus .env.* / .env-* variants (.env.local, .env.production) and SSH / private-key files (id_rsa, id_dsa, id_ecdsa, id_ed25519), all matched by filename rather than extension. JSON is excluded by default because API responses produce a high false-positive rate; add --scan-json to include it. A file named directly on the command line is scanned even if its extension is not in this list.

Exit codes

Code Meaning
0 No findings, or all resolved
1 Unresolved findings
2 Error (for example: bad path, dangerous --replacement, --ci --fix-all, a missing or invalid ingestion report, or --fail-on-error with an unreadable file)

Supply-chain hardening

A security tool should be safe to install, not only safe to run. Credactor's build and release pipeline is hardened end to end; full detail in the Security doc.

  • Zero runtime dependencies. A default pip install credactor pulls in no third-party packages (only the optional [encoding] extra), so there is nothing to vet at install time.
  • Hash-pinned toolchain. CI and release builds install from a --require-hashes lockfile, build backend included (python -m build --no-isolation against a pinned setuptools), so a tampered dependency fails the build.
  • Artifacts byte-checked against source. On every push and before every publish, scripts/audit_wheel.py compares the wheel and sdist to the committed source byte for byte (sha256 vs git HEAD); any added, missing, or altered file fails the gate, so a build step cannot inject code unnoticed.
  • SHA-pinned, least-privilege CI. GitHub Actions pin to commit SHAs, and workflow tokens stay narrow — contents: read by default, id-token: write only for the publish job.

Docs

Document Description
Setup Guide Installation, configuration, CI/CD integration
Manual Complete reference: every flag, mode, and combination, replacement and backup behaviour, detection and severity, exit codes, and limitations (behaviour test-verified)
Examples Common workflows with output
CI 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.

Metadata

Release files for credactor 2.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for credactor 2.7.2
File Size Uploaded Provenance
credactor-2.7.2.tar.gz 87.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for credactor 2.7.2
File Interpreter ABI Platform
credactor-2.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 177.0 kB

Release files / credactor-2.7.2.tar.gz

Download URL credactor-2.7.2.tar.gz
Size 87.7 kB
Tags Source
SHA-256 checksum
How to use checksums
de633fc202ae2513316906cabd67ce273f61e3fc115256d980263b6e5275bae0
BLAKE2b-256 checksum
How to use checksums
1c59c7ff37d8994012b91f58cbe01b8d6754ee51d3f8999ee40d8b71fa2b4d5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / credactor-2.7.2-py3-none-any.whl

Download URL credactor-2.7.2-py3-none-any.whl
Size 89.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a56aeb52f04fc9a34f0147c491a8e3d88cce0df72e77b1e91dba55ae4324b4d
BLAKE2b-256 checksum
How to use checksums
62ef8c01df368ac4af2462de9f3b670bcda6e8cd2cc288d2a7ff84bd7a1e31ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Security for credactor 2.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for credactor-2.7.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page