Hardn runtime protection (Python)
A small, defensive middleware you run inside your own app. It:
- labels automated-agent traffic from request headers and path (
score_agent), - serves honeytokens — decoy values and paths a real user never touches (
Honeytokens), - screens text for prompt-injection patterns before it reaches an LLM (
scan_prompt), - reports these signals to Hardn (
Telemetry) so you see them on your dashboard.
It never modifies your data and only calls out to Hardn's telemetry endpoint. Telemetry is fail-open: a network problem drops a batch of signals, it never breaks a request. Client IPs are hashed before they leave your process.
pip install hardn-runtime
Flask example
from flask import Flask, request, abort
from hardn_runtime import Telemetry, Honeytokens, score_agent, scan_prompt
app = Flask(__name__)
tel = Telemetry(api_key="hk_live_…", source="web-1")
honey = Honeytokens()
@app.before_request
def guard():
sig = score_agent(user_agent=request.headers.get("User-Agent"), path=request.path,
accept=request.headers.get("Accept"))
if sig.is_agent:
tel.record("agent_detected", ip=request.remote_addr, path=request.path, score=sig.score,
detail={"reasons": sig.reasons})
if honey.is_decoy_path(request.path):
tel.record("honeytoken_hit", ip=request.remote_addr, path=request.path, score=100)
abort(404) # behave like any other missing page
@app.post("/chat")
def chat():
result = scan_prompt(request.json.get("message", ""))
if result.flagged:
tel.record("injection_blocked", score=result.score, detail={"tactics": result.tactics})
# strip / review / reject as your policy requires
...
FastAPI / Starlette
Use the same calls from an http middleware or dependency; score_agent and scan_prompt are plain
functions, and Telemetry.record is safe to call from async code (it only buffers and occasionally POSTs).
What gets sent
Each signal is {kind, source, ip_hash, path, score, detail} where kind is agent_detected,
honeytoken_hit, injection_blocked or heartbeat. Call tel.flush() on shutdown to send the last batch.
Metadata
Release files for hardn-runtime 0.1.0
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 | Actions |
|---|---|---|---|---|
| hardn_runtime-0.1.0.tar.gz | 6.0 kB | Without provenance | Details for hardn_runtime-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hardn_runtime-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hardn_runtime-0.1.0-py3-none-any.whl |
Total release size: 13.0 kB
Release files / hardn_runtime-0.1.0.tar.gz
| Download URL | hardn_runtime-0.1.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
779b19c218b9c203871f66e794608cd15b8aa96cc9a6d9d379abfd7a5f0bd26f
|
|
BLAKE2b-256 checksum How to use checksums |
08388796d97c407474ae0c346d944bd74a8f7f42b77044b53ad4e46677b476db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / hardn_runtime-0.1.0-py3-none-any.whl
| Download URL | hardn_runtime-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d83236b65b8825b86d09b5abed7780a06a1cd8bd4b862553bc88b6b9197be254
|
|
BLAKE2b-256 checksum How to use checksums |
70c6b46994550530d1ceddc64b869788e49bea9ebd9feb2e23c27a4b0e1f43d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for hardn-runtime 0.1.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.
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.