Local-first redaction engine for AI egress security
Project description
EgressAI
EgressAI is a local-first redaction engine for AI egress security.
The first package takes text, detects secrets, replaces them with stable placeholders, and returns structured findings without exposing plaintext secret values in the public result.
Install
pip install egressai
The package depends on egressai-detect-secrets for provider-aware secret detection.
Python API
from egressai import RedactionEngine
secret = "sk-proj-" + "a" * 40
result = RedactionEngine().redact(f"OPENAI_API_KEY={secret}")
print(result.redacted_text)
Output:
OPENAI_API_KEY={{EGRESSAI_SECRET_OPENAI_001}}
Restore redacted text during the same engine session:
engine = RedactionEngine()
result = engine.redact(f"OPENAI_API_KEY={secret}")
restored = engine.restore(result.redacted_text)
The restore map is memory-only and is not included in structured output.
Structured result:
payload = result.to_dict()
The structured output includes:
redacted_textfindingsstats
Each finding includes zero-based character offsets (start, end) plus
one-based line and column metadata for locating the sensitive value in files,
logs, and pasted diffs.
Plaintext secret values are not included in result.to_dict().
CLI
Redact inline text:
egressai redact "OPENAI_API_KEY=sk-proj-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Redact a file:
egressai redact ./prompt.txt
Redact stdin:
cat ./logs.txt | egressai redact
Existing file paths are read from disk. Any other input is treated as literal text, including large multi-line contexts passed as one argument. For very large prompts or logs, stdin is usually the most reliable shell interface.
Return the full redaction result as JSON:
egressai redact --json ./sample.env
Scan without printing redacted text:
egressai scan ./sample.env
Return findings and stats as JSON:
egressai scan --json ./sample.env
Return one finding per JSON Lines record:
egressai scan --jsonl ./sample.env
Fail when findings are present:
egressai scan --fail-on-findings ./sample.env
Use a custom placeholder prefix:
egressai redact --placeholder-prefix SAFE ./prompt.txt
Exit Codes
By default, CLI commands exit 0 even when findings are detected.
With --fail-on-findings:
- exits
0when no findings are detected - exits
1when findings are detected - exits
2for CLI usage errors
Supported Secret Types
Initial support includes:
- OpenAI API keys
- Anthropic API keys
- Google/Gemini API keys
- GitHub tokens
- GitLab tokens
- AWS access keys
- Stripe keys
- Slack tokens
- npm tokens, including
.npmrcauth tokens andNPM_TOKEN=npm_...env values - PyPI tokens
- Hugging Face tokens
- JWTs, including JWT-like tokens with non-base64url signature suffixes
- private key blocks
- database URLs, including JSON-escaped URL values such as
postgres:\/\/... - Azure connection strings
- generic
.env-style secret assignments
Provider mappings are covered by tests so each supported detector returns the expected EgressAI type, detector name, and placeholder subtype.
The test suite includes a messy real-world fixture with a pasted user report, code diff, curl commands, runtime env vars, JSON payloads, repeated secrets, and multiple provider token types.
Release Notes
0.1.3
- Added finding
lineandcolumnmetadata. - Added same-session restore support through
RedactionEngine.restore(). - Added a messy real-world fixture corpus.
- Added JSON-escaped database URL redaction.
- Added
egressai scan --jsonl.
Maintainer Notes
Every user-visible change should update this README in the same change set.
Before publishing:
python3 -m pytest
python3 -m build
python3 -m twine check dist/egressai-*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file egressai-0.1.3.tar.gz.
File metadata
- Download URL: egressai-0.1.3.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ac90c10fcecc6848d962254a197b6f74693cb00f868cbd0d8f25fcc44f95b12
|
|
| MD5 |
353d9e00e6fccc86837cec9ef81f6e4b
|
|
| BLAKE2b-256 |
05092c320525a72e18c1001a40bbfab3fbd07b8a083f42a651894b0d2a0ba1f6
|
File details
Details for the file egressai-0.1.3-py3-none-any.whl.
File metadata
- Download URL: egressai-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a19346ecb31448ba72ef581fda94dd312f2507e2064224e9eae6846548d5e5d6
|
|
| MD5 |
e1c968e1f5cd52cf08c6f2127eed537b
|
|
| BLAKE2b-256 |
d438366ac8ada74283d5ea4bc437fe0e64df3183022aa27e61bd5a653e161008
|