Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Redact Secret for Python

Deterministic secret detection and redaction for runtime data and AI context, for CPython, over the same Rust core that backs the JavaScript, Rust, and CLI surfaces of Redact Secret. Every built-in detector runs in Rust; there is no pure-Python fallback implementation to drift from it.

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.

Install

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.

Use

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=<SECRET_1>\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.

Supported wheels

Platform Architectures Wheel tag
manylinux (glibc 2.17+) x86_64, aarch64 cp310-abi3-manylinux_2_17_*.manylinux2014_*
musllinux (musl 1.2+) x86_64, aarch64 cp310-abi3-musllinux_1_2_*
macOS 11+ x86_64, arm64 cp310-abi3-macosx_*
Windows x64, arm64 cp310-abi3-win_*

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.

Building from source

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.

Development

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/.

  • src/lib.rs owns CPython conversions, Unicode code point range conversion, and the synchronous scan/redact/scan_and_redact API: immutable finding and result types, sanitized exceptions, and the default policy and formatter helpers (decision-define-runtime-bindings).
  • src/incremental.rs owns the bounded incremental session: IncrementalSanitizer, its mandatory IncrementalLimits, the lifecycle states, and the incremental policy callback. Its CodePointIndex converts the core's absolute UTF-8 byte offsets to the absolute code point offsets a session reports, by recording only where the input's UTF-8 continuation bytes fall, never the characters themselves. Between successful calls it prunes offsets outside max_buffered_bytes; while processing a call it also indexes the incoming chunk, and its allocation can retain that peak capacity until the session ends. Bound host chunk sizes as well as session limits.
  • python/redact_secret/__init__.py re-exports the native module's public surface; python/redact_secret/_native.pyi and py.typed mark the package as typed.
  • tests/ runs against a built extension and exercises the shared conformance/ corpus, Unicode code point conversion, callback failure sanitization, placeholder safety, and determinism. The incremental suites add native-string partition invariance (test_incremental_partitions.py), astral character boundaries (test_incremental_unicode.py), and the canonical lifecycle, limit, callback, and failure-cleanup cases (test_incremental.py). They read the corpus from the repository, so they ship with neither the wheel nor the source distribution.
  • The extension-module Cargo feature is enabled only by maturin, so the crate still links during cargo test --workspace.
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.

Metadata

Release files for redact-secret 0.1.0b15

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

Source distribution (sdist)

Source distribution for redact-secret 0.1.0b15
File Size Uploaded Provenance Actions
redact_secret-0.1.0b15.tar.gz 897.9 kB With provenance Details for redact_secret-0.1.0b15.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for redact-secret 0.1.0b15
File Actions
redact_secret-0.1.0b15-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for redact_secret-0.1.0b15-cp310-abi3-win_arm64.whl
redact_secret-0.1.0b15-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for redact_secret-0.1.0b15-cp310-abi3-win_amd64.whl
redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_x86_64.whl
redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_aarch64.whl
redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
redact_secret-0.1.0b15-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for redact_secret-0.1.0b15-cp310-abi3-macosx_11_0_arm64.whl
redact_secret-0.1.0b15-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for redact_secret-0.1.0b15-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 7.6 MB

Release files / redact_secret-0.1.0b15.tar.gz

Download URL redact_secret-0.1.0b15.tar.gz
Size 897.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cba17a170ea2d0f861d7878d6bb32c7369c2b83b269db63984401bbb10c04523
BLAKE2b-256 checksum
How to use checksums
750ec31d75ce1d8f87a8282c63276d94d88837db9e7fbe93bf9066f1d85a2747
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-win_arm64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-win_arm64.whl
Size 674.2 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f0858dfc6ffe32e3b01a5b1d7089f9870547073287fd3d174bdb5c17117c1e60
BLAKE2b-256 checksum
How to use checksums
7ebfd0b3c8eda624bf4a358d2076723ff3d7746cd935d18130ca35747a07e091
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-win_amd64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-win_amd64.whl
Size 711.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b9e6963de6c64d1f5cfa070200cd626f6d39dcc02d4777c2e153a1bc4a850f12
BLAKE2b-256 checksum
How to use checksums
a7f546cf27b00010f2c322d519ff2781d6ad24892014ee1d4bb67747431c10fa
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
bb1eb65f5841b765ea551d9d0fe24d2f0b3cec0cb42eb59c857a939290ae3211
BLAKE2b-256 checksum
How to use checksums
9daab9cf016c921a12082433c75245976cdb33e9efef7dab33b87577015870d8
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-musllinux_1_2_aarch64.whl
Size 1.0 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
4d483a1f58e2387420043a628c6046cc9fdfb546f5f80864d7a0029bb23e9aa8
BLAKE2b-256 checksum
How to use checksums
cb862cb2a6000fb94fe9a467ee1f5413780f40881e38003cdb366ab56e543b48
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 844.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f614a2838cc553425a6a27ae83ba1891ea6a85054debd6bc948a20329d05fe4b
BLAKE2b-256 checksum
How to use checksums
c179708ee88104dda1c0f73f1fb3398d991dd1d792fdf0d0c94ebfeabfcfb2cd
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 827.3 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
6dc94207683c3208aa146b349ce9b738b49bb0f6a4abd01f4be36b6fbce28037
BLAKE2b-256 checksum
How to use checksums
67fd38cf9b79010f50c5e3b3df7989b31d69e49e2d73de05b0ff23721581d46e
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-macosx_11_0_arm64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-macosx_11_0_arm64.whl
Size 781.6 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ea753c30eb73d66831ccce5d934230894036617069aa5c5d118002606ecb6d25
BLAKE2b-256 checksum
How to use checksums
76501fa6b301fcdab89975e18dd67d186a7b17ea40cfcfe62daa86308d52c4a5
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 Oct 10, 2026.

Transparency log

Release files / redact_secret-0.1.0b15-cp310-abi3-macosx_10_12_x86_64.whl

Download URL redact_secret-0.1.0b15-cp310-abi3-macosx_10_12_x86_64.whl
Size 806.1 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b8a1b698834c48e18aa3c78adda584a69cbc7a1df7a882fe66bf59598fb5ffa8
BLAKE2b-256 checksum
How to use checksums
3678435f61f67c9a15d18438855d91f777c9761db1d2728d128088fe2b913ee9
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 Oct 10, 2026.

Transparency log

Security for redact-secret 0.1.0b15

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 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for redact_secret-0.1.0b15.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 Oct 10, 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