clawdstrike
Python SDK for Clawdstrike security verification.
Installation
pip install clawdstrike
Quick Start
from clawdstrike import Clawdstrike
cs = Clawdstrike.with_defaults("strict")
# Check file access
decision = cs.check_file("/etc/shadow")
if decision.denied:
print(f"Blocked: {decision.message}")
# Check network egress
decision = cs.check_network("api.openai.com")
print(f"Allowed: {decision.allowed}")
Usage
Facade API (recommended)
from clawdstrike import Clawdstrike, Decision, DecisionStatus
# Built-in rulesets: "permissive", "default", "strict", "ai-agent", "cicd"
cs = Clawdstrike.with_defaults("strict")
# All check methods return a Decision
decision = cs.check_file("/etc/passwd")
decision = cs.check_command("rm -rf /")
decision = cs.check_network("evil.com", 443)
decision = cs.check_patch("/app/main.py", diff_str)
decision = cs.check_mcp_tool("shell_exec", {"cmd": "ls"})
# Decision properties
print(decision.status) # DecisionStatus.DENY
print(decision.denied) # True
print(decision.allowed) # False
print(decision.message) # "Access to forbidden path: ..."
print(decision.guard) # "forbidden_path"
print(decision.per_guard) # List of individual GuardResult objects
Sessions
cs = Clawdstrike.with_defaults("default")
session = cs.session(agent_id="my-agent")
session.check_file("/app/src/main.py")
session.check_network("api.openai.com")
session.check_file("/home/user/.ssh/id_rsa")
summary = session.get_summary()
print(f"Checks: {summary.check_count}")
print(f"Allowed: {summary.allow_count}")
print(f"Denied: {summary.deny_count}")
print(f"Blocked: {summary.blocked_actions}")
Loading from YAML
from clawdstrike import Clawdstrike
# From file
cs = Clawdstrike.from_policy("policy.yaml")
# From YAML string
cs = Clawdstrike.from_policy('''
version: "1.1.0"
name: my-policy
extends: strict
guards:
egress_allowlist:
allow:
- "api.myservice.com"
''')
Low-level API
from clawdstrike import Policy, PolicyEngine, FileAccessAction, GuardContext
policy = Policy.from_yaml_file("policy.yaml")
engine = PolicyEngine(policy)
context = GuardContext(cwd="/app")
results = engine.check(FileAccessAction(path="/app/src/main.py"), context)
print(all(r.allowed for r in results))
Native Engine (Recommended)
The SDK automatically uses the bundled native engine when available. All 12 guards run in Rust with full detection capabilities.
On unsupported platforms, the SDK falls back to pure Python with 9 guards and heuristic-only detection.
Native wheels are published for:
- Linux:
manylinux(x86_64,aarch64) - macOS:
x86_64,arm64 - Windows:
x86_64
from clawdstrike import Clawdstrike, NATIVE_AVAILABLE, init_native
# Check if native engine is available
print(f"Native available: {NATIVE_AVAILABLE}")
print(f"Native engine: {init_native()}")
# The facade auto-selects the best backend
cs = Clawdstrike.with_defaults("strict")
print(f"Backend: {cs._backend.name}") # "native" or "pure_python"
Explicit Backend Selection
from clawdstrike import Clawdstrike
from clawdstrike.backend import DaemonEngineBackend, NativeEngineBackend, PurePythonBackend
from clawdstrike.policy import Policy, PolicyEngine
# Force pure Python backend
yaml = 'version: "1.1.0"\nname: test\nextends: strict\n'
policy = Policy.from_yaml_with_extends(yaml)
cs = Clawdstrike(PurePythonBackend(PolicyEngine(policy)))
# Force native backend (raises if unavailable)
backend = NativeEngineBackend.from_ruleset("strict")
cs = Clawdstrike(backend)
# Force daemon-backed evaluation through hushd
daemon = DaemonEngineBackend("https://hushd.example.com", api_key="dev-token")
cs = Clawdstrike(daemon)
Origin-Aware Checks
Origin-aware enforcement is available on:
- the bundled native Rust backend
- hushd via
Clawdstrike.from_daemon(...)orDaemonEngineBackend
The pure-Python backend does not enforce policy.origins. It fails closed with
UnsupportedOriginFeatureError if you pass origin or use origin.output_send.
from clawdstrike import Clawdstrike
origin = {
"provider": "slack",
"tenant_id": "T123",
"space_id": "C456",
"actor_role": "incident_commander",
}
cs = Clawdstrike.from_daemon("https://hushd.example.com", api_key="dev-token")
decision = cs.check_mcp_tool(
"read_file",
{"path": "/srv/runbook.md"},
origin=origin,
)
send_decision = cs.check_output_send(
"Posting sanitized status update",
target="slack://incident-room",
mime_type="text/plain",
metadata={"thread_id": "1712502451.000100"},
origin=origin,
)
Per-check origin changes also work through sessions:
session = cs.session(session_id="sess-123", agent_id="triage-bot")
session.check_file(
"/srv/runbook.md",
origin={"provider": "github", "space_id": "repo-1"},
)
session.check_output_send(
"Ready for review",
target="slack://incident-room",
origin={"provider": "slack", "space_id": "C456"},
)
Features
- Native Rust engine (bundled in
clawdstrikewheels on supported platforms) with all 12 guards - Pure Python fallback with 9 guards:
- ForbiddenPathGuard - Blocks sensitive filesystem paths
- PathAllowlistGuard - Allowlist-based path access control
- EgressAllowlistGuard - Controls network egress by domain
- SecretLeakGuard - Detects secrets in file writes
- PatchIntegrityGuard - Validates patch safety
- ShellCommandGuard - Blocks dangerous shell commands
- McpToolGuard - Restricts MCP tool invocations
- PromptInjectionGuard - Detects prompt injection
- JailbreakGuard - Detects jailbreak attempts
- Facade API with
Clawdstrikeclass andDecisionreturn type - Stateful sessions with
ClawdstrikeSession - Custom exception hierarchy (
ClawdstrikeErrorbase) - Policy engine with YAML configuration and inheritance
- Receipt signing and verification with Ed25519
- Typed action variants (frozen dataclasses)
License
Apache-2.0
Release files for clawdstrike 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clawdstrike-0.2.7.tar.gz | 234.8 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| clawdstrike-0.2.7-py3-none-any.whl | Python 3 | none | any | Details |
| clawdstrike-0.2.7-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| clawdstrike-0.2.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| clawdstrike-0.2.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| clawdstrike-0.2.7-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| clawdstrike-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 23.2 MB
Release files / clawdstrike-0.2.7.tar.gz
| Download URL | clawdstrike-0.2.7.tar.gz |
|---|---|
| Size | 234.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b91ee63726e6e821811b28138454db87fca810203d568b6036e0febec5ef85d
|
|
BLAKE2b-256 checksum How to use checksums |
39317c3623a7eabe4fd127b12e3c8b4a1cc8f67e9013afe518b468eb6f081543
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / clawdstrike-0.2.7-py3-none-any.whl
| Download URL | clawdstrike-0.2.7-py3-none-any.whl |
|---|---|
| Size | 143.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5291d2e23dc9ada25a82ceebe69e17b9db85f6f5f31f4f6ee5042710e90441dc
|
|
BLAKE2b-256 checksum How to use checksums |
e6ed200e40b5b3d408902fae1a2becb0ef952114636c729fa4d312e653e87040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / clawdstrike-0.2.7-cp310-abi3-win_amd64.whl
| Download URL | clawdstrike-0.2.7-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0e88cb958137f37eb9a3ed717714dd19be7767329cd208a177d98f3e93d1dc0e
|
|
BLAKE2b-256 checksum How to use checksums |
d70a158c3e033711c40e08b57219a31a9e321426324390943ece4cadccad6027
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / clawdstrike-0.2.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | clawdstrike-0.2.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.8 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1dd2c39a2b1f1ac5fd047898c95b17e2aa6b739e7f97234a07eb09d9dc67bcf2
|
|
BLAKE2b-256 checksum How to use checksums |
7698a1e6f74f108d033c682713c66b40027ec96c317f8d9d7b396ec420d66b4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / clawdstrike-0.2.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | clawdstrike-0.2.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
fcde30a479c852a112a0b2a7ccf51e738b736b446a465d7a218799606d115fc2
|
|
BLAKE2b-256 checksum How to use checksums |
7acbbaa4e698655ef79c8f7e58ed1d972aeac5282f9f62b371b6c4d0d4f1186c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / clawdstrike-0.2.7-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | clawdstrike-0.2.7-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.4 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
46b4a32495d3ccaa471957ecfa70a7c5b18a822c61db656149c7fed70d6a162f
|
|
BLAKE2b-256 checksum How to use checksums |
401fb0d96cfc2dda0116606876f18a2dc4db0263321880bda2894c74ee93c6fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / clawdstrike-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | clawdstrike-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
7527be5de909f14a51bb46bd7d15475123cdf30d8d7362a53ce2a4deefc19275
|
|
BLAKE2b-256 checksum How to use checksums |
932b7c92e069619f18fed41a1ab292a0328608dec29c51ecadf96bcf6583a98b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|