This release is a pre-release and may not be stable for production use.
Deterministic secret detection and redaction for runtime data and AI context: scans text locally before it reaches logs, storage, telemetry, tools, or model context. CPython binding for the redact-secret core.
pip install redact-secret==0.1.0b15 Copy PIP instructions
Scan text in your process before it reaches logs, persistence, telemetry, tool output, or model context. Detection is local and deterministic: no network calls, no telemetry, and the same input always gives the same result. Findings never include the matched secret.
Redact Secret is not a DLP platform and does not detect every secret: it finds supported credential formats and, only when you opt in, six bounded structured PII families (at the Beta.11 qualification: five provisional, US SSN pending, none stable), and an empty finding list does not prove text is secret-free. It complements repository and history scanners rather than replacing them. Credential-family support is published in the generated support matrix, not stated by hand here; that matrix does not carry the PII families, whose statuses are in the detection reference.
The distribution is redact-secret and the import name is redact_secret. The product name is Redact Secret everywhere; per PEP 503, redact-secret and redact_secret normalize to the same PyPI project identity, so no registry fallback name is needed — see docs/rust-workspace.md.
The version in the development manifests is not a published release. See release status for installable versions.
This directory is the canonical Python binding decision-release-bindings-in-lockstep requires before the separately created secret-scan-python GitHub repository is archived with a redirect to here. That repository does not currently exist under the redact-secret organization; re-verify its status before executing the archive. The prepared redirect text lives in docs/python-repository-redirect.md.
pip install redact-secret Wheels are CPython 3.10+ abi3: one wheel per platform serves every supported interpreter, and installing one needs no Rust toolchain and no compiler. See Supported wheels. Where no wheel applies, pip falls back to the source distribution, which does need Rust — see Building from source.
import redact_secret findings = redact_secret.scan(text) redacted = redact_secret.redact(text, findings) # or, to guarantee the findings and the redacted text agree: result = redact_secret.scan_and_redact(text) result.text, result.findings Ranges on every DetectedFinding and Finding are Unicode code point offsets (redact_secret.RANGE_UNIT == "unicode-code-points"), so they index a str the way Python itself does.
scan, redact, and scan_and_redact default to a 64 MiB input bound and a 50,000 finding-count bound, raising InputLimitExceededError/ FindingLimitExceededError rather than returning a truncated result. Pass limits=redact_secret.WholeInputLimits(max_input_bytes=..., max_findings=...) to raise or lower them.
scan_and_redact returns a ScanResult whose text is the same str on every read. Each read of findings returns a new list that holds the same Finding objects, so changing the list never changes the result. Detection releases the GIL, so threads can scan in parallel; policy and formatter callbacks still run on the calling thread.
For input that arrives in pieces, IncrementalSanitizer sanitizes a bounded session chunk by chunk. Independently scanning chunks is unsafe, because a credential may cross any chunk boundary; a session carries the boundary state that makes it safe. Limits are mandatory and are counted in UTF-8 bytes:
limits = redact_secret.IncrementalLimits( max_input_bytes=1_000_000, max_buffered_bytes=32_896, max_token_bytes=8_192, max_multiline_bytes=32_768, ) with redact_secret.IncrementalSanitizer(limits) as session: first = session.append("api_key=SYNTHETIC_REVOKED_") second = session.append("INCREMENTAL_VALUE\nordinary text") final = session.finalize() safe_text = first.text + second.text + final.text # api_key= \nordinary text Leaving the with block aborts a session that was not finalized, so whatever it still retained is discarded. A session's findings carry absolute code point offsets into the logical whole-session input, so they index "".join(chunks) exactly as the synchronous API's findings index the same joined string.
policy and formatter callbacks receive only normalized safe metadata, never the input or a matched value. A callback that raises, or that returns something other than the documented protocol, never propagates its own error: it becomes one of the fixed SecretScanError subclasses. There is no custom detector callback surface.
redact_secret.artifact_manifest() returns the wheel's artifact-manifest/v1 document as a dict: the built-in detectors in canonical order with the finding types each can emit, the PII runtime, capabilities, defaults, bounds and a digest. It takes no input, builds no registry and reads no PII selection, so calling it never initializes or locks initialize(pii=...). Each types list is a detector's declared types, not a closed vocabulary.
The package is typed (PEP 561): the wheel ships py.typed and a _native.pyi stub, so type checkers resolve the API without a stub package.
Every wheel in that matrix is built and smoke-tested on its own architecture, on CPython 3.10 and 3.14, before a release candidate is accepted; see docs/python-packaging.md.
The source distribution needs a Rust toolchain at or above the workspace MSRV (1.88, Rust 2024 edition). With cargo on PATH, pip install builds it like any other source install.
Without one, maturin's build backend downloads a toolchain into a local cache and continues. To refuse that instead and fail immediately with Cargo metadata failed. Do you have cargo in your PATH?, set:
MATURIN_NO_INSTALL_RUST=1 pip install --no-binary redact-secret redact-secret Set it in any environment that must not fetch a toolchain over the network.
This directory is a mixed Rust/Python maturin project. The crate is redact-secret-python, the native module is redact_secret._native, and the pure Python package lives under python/redact_secret/.
cd bindings/python python3 -m venv .venv && source .venv/bin/activate pip install '.[test]' maturin pytest maturin develop pytest Rebuild with maturin develop after any change under src/; pytest imports the installed extension, not the Rust sources.
Packaging identity, the abi3 contract, and the wheel matrix are declared in [workspace.metadata.redact-secret] in the root Cargo.toml and enforced by scripts/check-python-package.py. Build and qualify artifacts with scripts/qualify-python-wheel.py; see docs/python-packaging.md.
secret-detection redaction security credentials sanitization
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Enable javascript to be able to filter the list of wheel files.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.




