Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

pii-shield-wasi

PII redaction scanner powered by the core Go engine compiled to WebAssembly (WASI). It runs in-process — no network hop — using hybrid heuristic and entropy-based detection.

Installation

pip install pii-shield-wasi

Requires Python 3.9+ and wasmtime 45.0.0+ (pulled in by pip). On macOS this includes Apple's /usr/bin/python3: the SDK turns off wasmtime's Mach-port trap handler there, which Apple-signed interpreters do not allow and which used to get the process killed (Killed: 9) on the first call.

Usage

from pii_shield import PiiShield, PiiShieldConfig

# Initialize the scanner with optional configuration overrides
shield = PiiShield(PiiShieldConfig(
    entropy_threshold=4.0,
    confidence_score=0.8
))

text = "Connecting to DB with password: MySuperSecretPassword123!"
redacted_text = shield.redact(text)

print(redacted_text)
# Output might redact the high entropy secret based on context

redact() accepts multi-line text. Each line is scanned independently and \n / \r\n endings are preserved, so the output has exactly as many lines as the input (the same contract the CLI gives stdin).

Configuration

PiiShieldConfig accepts these overrides. Any field left unset keeps the core scanner default, so redaction matches the CLI for the same config.

Option Type Description
entropy_threshold float Shannon entropy cut-off for candidate tokens.
confidence_score float Hybrid-validation confidence threshold.
salt str HMAC salt for the [HIDDEN:xxxxxx] tags. Treat it as a secret: anyone who has it can compute the tag of a guessed value. If unset, each instance draws a random salt, so tags match only within that instance; set the same salt in every process that must produce matching tags.
min_secret_length int Minimum candidate token length before entropy checks apply.
sensitive_keys list[str] Key names whose values are always redacted (case-insensitive). Replaces the defaults.
disable_bigram_check bool Disable English bigram analysis (useful for non-English logs).
adaptive_threshold bool Enable the experimental statistical adaptive-threshold mode.
entity_type_labels bool Emit [HIDDEN:<type>:<hash>] markers, where <type> names the detector that fired: card, key, context, url, regex, entropy, or one of the issuer-format detectors aws-key, gcp-key, github-token, slack-token, stripe-key, jwt, telegram-bot-token, and private-key (a PEM private-key framing line). A named custom rule uses its own name. Off by default; the hash is unchanged.
sensitive_key_patterns list[str] Regex patterns matched against key names (equivalent to PII_SENSITIVE_KEY_PATTERNS).
custom_regexes list[dict] Rules forcing redaction: [{"pattern": ..., "name": ...}] (equivalent to PII_CUSTOM_REGEX_LIST).
safe_regexes list[dict] Whitelist rules exempting matching tokens (equivalent to PII_SAFE_REGEX_LIST).
fail_policy "open" | "closed" On an internal error, open returns the input unchanged; closed returns a drop marker. Handled in this wrapper.

Invalid regex handling

A bad pattern can never terminate your Python process. An invalid custom_regexes or safe_regexes entry is skipped and the rest of the list is applied; each skipped rule is reported with a WARNING on stderr. (Before version 2.2.4 one invalid entry silently dropped the whole list, so a single stray bracket switched off every rule in it.) An invalid sensitive_key_patterns entry disables that pattern list with a warning. The CLI behaves the same way for its environment-variable lists. Validate patterns before rollout if you need strictness — a skipped custom rule means its matches are no longer force-redacted.

Features

  • In-process: runs the Go WASM binary inside Python via Wasmtime — no network hop by construction.
  • Low-allocation hot path: the scan loop is optimized to reduce garbage-collection overhead during large log streaming.
  • Hybrid scoring: combines static whitelists, regex heuristics, and Shannon entropy, which helps avoid false positives on structured values like UUIDs and IPv6 addresses.

Metadata

Release files for pii-shield-wasi 3.0.0

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for pii-shield-wasi 3.0.0
File Size Uploaded Provenance Actions
pii_shield_wasi-3.0.0.tar.gz 1.6 MB With provenance Details for pii_shield_wasi-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pii-shield-wasi 3.0.0
File Interpreter ABI Platform Actions
pii_shield_wasi-3.0.0-py3-none-any.whl Python 3 none any Details for pii_shield_wasi-3.0.0-py3-none-any.whl

Total release size: 3.3 MB

Release files / pii_shield_wasi-3.0.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL pii_shield_wasi-3.0.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
1a1931ef4b4158e0dc7adbd7dbd23d0e39bf3bf4c65fa56190ce0f339d47e593
BLAKE2b-256 checksum
How to use checksums
71e2e95786419be4a361b896d33f299f2227d568dfe76e25162bdd271b61de2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 2, 2026.

Transparency log

Release files / pii_shield_wasi-3.0.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL pii_shield_wasi-3.0.0-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
5e105168b42517ac8aebf1b5d6de817bc1760cac45162fa54806d5ee93af31bd
BLAKE2b-256 checksum
How to use checksums
a4c582eb6383d0e6730dd6dc59f1d925380a3e91794eaa6f7e9a214344528c11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 2, 2026.

Transparency log

Security for pii-shield-wasi 3.0.0

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.

Change of provenance

The configuration that created this release differs from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for pii_shield_wasi-3.0.0.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 Nov 2, 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.

Release history Release notifications | RSS feed

This release
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