nemesis-shield - Python SDK
Native Python SDK for Nemesis Shield. Computes a privacy-preserving request sketch locally, learns your app's normal behavior, and - in enforce mode - blocks off-baseline requests (auth bypass, path traversal, scanners, unusual methods) before your views ever run. Positive-security: this app only ever behaves in these ways. Zero dependencies (stdlib only). Fail-open: if Nemesis is unreachable, your app is unaffected.
pip install nemesis-shield
One line per framework
FastAPI / Starlette (ASGI)
from nemesis_shield.asgi import SentinelMiddleware
app.add_middleware(SentinelMiddleware, token=os.environ["NEMESIS_TOKEN"])
Flask / any WSGI app
from nemesis_shield.wsgi import SentinelWSGI
app.wsgi_app = SentinelWSGI(app.wsgi_app, token=os.environ["NEMESIS_TOKEN"])
Django - add to settings.py and set NEMESIS_TOKEN in the environment:
MIDDLEWARE = ["nemesis_shield.django.SentinelDjango", *MIDDLEWARE]
Raw / anything - use the client directly:
from nemesis_shield import build_sketch
from nemesis_shield.client import SentinelClient
c = SentinelClient(token=os.environ["NEMESIS_TOKEN"])
c.record(build_sketch(method="GET", path="/orders/42", authenticated=True, status=200))
Docs & links
Want more than the one-liner? Full per-framework code, options, and examples:
| Framework | Detailed guide & source |
|---|---|
| FastAPI / Starlette (ASGI) | nemesis_shield/asgi.py |
| Flask / WSGI | nemesis_shield/wsgi.py |
| Django | nemesis_shield/django.py |
| Raw client | nemesis_shield/client.py |
| LLM guard | nemesis_shield/llm.py |
| Runnable examples | python/tests |
- Full docs & source: https://github.com/eobi/nemesis_shield_sdks/tree/main/python
- Website & console: https://shield.nemesislabs.xyz
How enforcement works
- Learn - deploy in observe mode (default). Every request is recorded as a privacy-preserving request signature (method + route + params + auth - never bodies or secrets). Review and approve the learned behaviors in the console.
- Enforce - flip the app to enforce in the console. The SDK polls the compiled allow-list in the background, so no redeploy is needed - the console is the source of truth.
- Block - any request whose signature isn't in the approved allow-list (once a baseline exists),
is explicitly blocked, or matches global threat intel, gets a
403 blocked_by_nemesis_shieldbefore your app handles it. Everything approved passes untouched.
Verified end-to-end (learn → enforce → attack) on FastAPI, Flask, Django and raw: legitimate traffic passes (200) while auth bypass, BOLA, path traversal and scanner probes are blocked (403) and reported.
LLM protection
from nemesis_shield import analyze_llm
result = analyze_llm(prompt=prompt, system=system, response=response, tools=tools)
MIT © Autogon Inc.
Full coverage & safe-unlock
Mount it first / outermost so every route is inspected (not just API routes - attackers hit any path):
app.add_middleware(SentinelMiddleware, token=os.environ["NEMESIS_TOKEN"]) # ASGI; or wrap wsgi_app outermost
What's inspected (privacy-preserving): method + normalized route + query-param structure (names + kinds, never values) + auth flag + status. An off-baseline route, param structure, method, or auth state is blocked in enforce mode. Path-traversal segments normalize to {traversal}.
Safe-unlock (break-glass): the login/auth path is never blocked, so a still-learning baseline can't lock you out. Defaults: /login /signin /sign-in /auth /oauth /session /wp-login.php /wp-admin. Override:
export NEMESIS_SHIELD_BOOTSTRAP="/login,/admin,/healthz"
Verify coverage - in observe mode, hit a normal route, a param, and a scanner path, then confirm all three appear in the console (Activity / Behaviors):
curl -s "http://localhost:8080/" >/dev/null
curl -s "http://localhost:8080/search?q=shoes" >/dev/null
curl -s "http://localhost:8080/.env" >/dev/null # shows up as an off-baseline behavior
Metadata
Release files for nemesis-shield 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nemesis_shield-0.1.4.tar.gz | 50.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nemesis_shield-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 96.9 kB
Release files / nemesis_shield-0.1.4.tar.gz
| Download URL | nemesis_shield-0.1.4.tar.gz |
|---|---|
| Size | 50.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f281e9d3a117d3dfacd2eebc327f056f293ae64cfc97d71534c44d991df83b76
|
|
BLAKE2b-256 checksum How to use checksums |
3bc08eb06c21c77c13e8c13ec34548bbb42e9ea1d075b6787f9b25216ae6f835
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Release files / nemesis_shield-0.1.4-py3-none-any.whl
| Download URL | nemesis_shield-0.1.4-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfba489ff9c512ad2bd20c2da993a3624419a16468a2caee571d67b18db15dd6
|
|
BLAKE2b-256 checksum How to use checksums |
9240dad82d68701bf67b7bc3ba4250b5f87e7d263a27f746d9e90b744c91635a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Security for nemesis-shield 0.1.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.