- Findings
- –
- Entity types
- –
- Highest severity
- –
- Characters
- –
- Engine time
- –
Findings
Matched values stay hidden unless you reveal them, the same default as
safestream detect (--show-text reveals them).
| Value | Replaced by |
|---|
policy.toml
The settings on the left as a policy file. Edit either side; the other follows.
Checked by the same loader as --config policy.toml.
Run this yourself
The current settings, ready to paste. Your files never leave your machine.
The engine never holds the whole input. It reads a chunk, scans it together with an overlap carried from the last pass, writes out what is safe, and repeats. Step through the passes to watch the window move while its size stays fixed.
- Passes
- –
- Findings
- –
- Boundary retreats
- –
- Largest window
- –
- Input size
- –
written read-only context written by this pass carried to the next pass
Memory stays flat as input grows
Generate a synthetic service log of each size inside the engine and stream it
through redact_stream, as safestream redact streams a file. Each size
runs twice: once timed, once under Python's tracemalloc
to measure the peak memory the engine allocates. The log is generated as it is read and the
output is hashed as it is written, so neither is ever held whole.
Faster, on your machine
Runs locally, not in this pageThis page runs one copy of the pure-Python engine inside WebAssembly. Installed
locally, the same package adds a Rust core and multi-core workers with byte-identical output.
From the README: about 1.1–1.4 MB/s per core in pure Python and 3–17 MB/s with the native core,
and --workers N scales across cores.
pip install 'git+https://github.com/MounishSenisetty/SafeStream-Redactor#subdirectory=native' # needs Rust safestream redact huge.log -o clean.log --backend native --workers 8
This is the API safestream serve exposes on your machine
(127.0.0.1:8000). Here the same request handler answers inside your browser, with the
settings on the left.
Endpoints
| Method | Path | Body | Returns |
|---|---|---|---|
| GET | /health | – | {"status": "ok"} |
| GET | /version | – | tool name and version |
| GET | /detectors | – | active tiers and every entity type |
| POST | /redact | {"text": "..."} | redacted text and counts by type |
| POST | /scan | {"text": "..."} | offsets, types and confidence, never the matched text |
Errors: 400 bad JSON or no string text, 404 unknown
route, 411 chunked body, 413 body over the limit (8 MiB by default). Request bodies are never logged.
safestream mcp-serve gives an AI agent redaction tools over the
Model Context Protocol. The tools report what was found and
where, never the secret itself. Send the same JSON-RPC
messages an agent would.
Connect your MCP client
Install the package, then add this to your client's configuration (Claude Desktop, Cursor, and others). It follows the settings on the left: anything other than the defaults goes through a policy file.
Tools
| Tool | Input | Returns |
|---|---|---|
scan | {"text"} | type, offsets, length, confidence, severity, detector: no secret text |
redact | {"text"} | the text with secrets removed, and counts |
explain_detection | {"text"} | why each finding was flagged: no secret text |
detectors | {} | active tiers, their streaming requirements, the overlap |
health | {} | version, tiers, protocol, offline status |
safestream detect --fail-on-detect exits with status 1 when it finds
anything, which fails a commit hook or a CI job. It reports file:line:col and the type,
never the secret. Paste a file or a diff: the real command runs on it here.
The command scans the whole text it is given, removed lines of a diff included. As a pre-commit hook it receives the staged files themselves.
Pre-commit hook
GitHub Action
The SARIF report is content-free, so it is safe to upload to code scanning.
Exit codes
0 | Success: nothing found |
1 | --fail-on-detect found something, or a runtime error (unreadable input, invalid config) |
2 | Invalid command-line usage |
3 | The run could not fit in --memory-limit |
Which one do I need?
pip
pip install safestream-redactor
Python 3.10 or newer on Linux, macOS or Windows. No third-party runtime dependencies.
Only need the command? pipx install safestream-redactor, or without installing:
uvx safestream-redactor --help.
Docker
docker run --rm --network none --user "$(id -u):$(id -g)" -v "$PWD":/data \
ghcr.io/mounishsenisetty/safestream-redactor redact /data/app.log -o /data/clean.logMulti-architecture images (amd64, arm64) with an SBOM and provenance. --network none runs it with no network at all.
From a clone
git clone https://github.com/MounishSenisetty/SafeStream-Redactor cd SafeStream-Redactor pip install -e '.[dev]' pytest
For contributors: tests, benchmarks and the latest main.
Optional extras
[ui] | The local web playground (Streamlit), for files up to 2 GB |
[crypto] | Reversible --mode encrypt and safestream deanonymize |
[ner] | spaCy names, organisations and locations (--ner) |
[onnx] | An on-device ONNX NER model you supply (--onnx) |
[all] | native, ui and crypto together |
Not in this browser demo
These parts of the product need your machine. Nothing below runs in this page; each panel gives the command to run it yourself.
Offline proof
LiveCounted from the browser's own resource-timing records. Every run, sample, upload and console call above is processed in this tab. The Content-Security-Policy below makes the browser refuse any connection to another site, for the page and for the engine's worker:
How it works
- Stream through a fixed window. Text is read in chunks into a rolling buffer of one chunk plus an 8 KiB overlap. Only text at least one overlap from the end of the buffer is written each round; the rest is carried into the next, so an entity cut by a chunk boundary is still seen whole. Memory never grows with input size.
- Detect in tiers. Patterns with validators (Luhn, SSN rules, …), entropy scoring for unknown secrets, and optional NER (spaCy or ONNX) find candidates; contextual scoring, a confidence filter and overlap resolution decide what is kept.
- Rewrite by policy. Each kept span is replaced: replace, mask, pseudonymize, hash, encrypt or fictionalize. Everything outside a redacted span, line endings included, comes out byte for byte as it went in.
text chunks ──> [ rolling buffer: chunk + 8 KiB overlap ] ──> redacted chunks
│
┌────────────────────────┼─────────────────────────┐
▼ ▼ ▼
patterns + validators entropy scoring NER (optional)
(Luhn, SSN rules, …) for unknown secrets spaCy or ONNX
└────────────────────────┼─────────────────────────┘
▼
contextual scoring ─> confidence filter ─> overlap resolution
▼
redaction policy: replace, mask, pseudonymize, hash, encrypt, fictionalize
From the README. In this page the NER tier is not available (see Install → Not in this browser demo).
Limitations
No tool can guarantee every name or free-form identifier in prose is found: "April" is a name and a month,
and an account number looks like any other run of digits. SafeStream is tuned for high precision on structured
PII and credentials. For names, enable [ner] or [onnx]. For identifiers without a fixed
format, add label-anchored patterns, as in examples/policy.toml. Review redacted output before
sharing it anywhere a miss would be costly.
Where it loses, from the README's evaluation: Presidio's transformer engine redacts more entities fully, and wins on ai4privacy. SafeStream misses values inside structured fields, unlabelled ID numbers, many international phone formats, and many names.
This demo, specifically
- Text typed or dropped here is capped at 1 MiB; the CLI streams files of any size.
- It runs the pure-Python engine on one thread inside WebAssembly, slower than a local install.
- The spaCy and ONNX name tiers, encrypt mode, the native core, multi-core workers and kernel-enforced offline mode need your machine (Install tab).
- The in-process network guard is defence in depth, not a sandbox. Locally,
--offline-hardon Linux ordocker run --network noneadds a hard boundary.
Full results: docs/EVALUATION.md. Threat model: SECURITY.md.