Skip to content

Commit 6459250

Browse files
author
ConnorWhelan11
committed
fix plugin and docs
1 parent 67a3a22 commit 6459250

File tree

9 files changed

+490
-77
lines changed

9 files changed

+490
-77
lines changed

docs/src/concepts/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The intended integration is at the **tool boundary** (your agent runtime calls C
5858
|---------|-------------|
5959
| `@clawdstrike/sdk` | Crypto/receipts + a subset of guards + prompt-security utilities (no full policy engine) |
6060
| `@clawdstrike/adapter-core` | Framework-agnostic adapter interfaces |
61-
| `@clawdstrike/openclaw` | OpenClaw plugin |
61+
| `@clawdstrike/clawdstrike-security` | OpenClaw plugin (plugin id: `clawdstrike-security`) |
6262
| `@clawdstrike/vercel-ai` | Vercel AI SDK integration |
6363
| `@clawdstrike/langchain` | LangChain integration |
6464
| `@clawdstrike/hush-cli-engine` | Node.js bridge to Rust CLI |
Lines changed: 98 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
1-
# OpenClaw Integration (experimental)
1+
# OpenClaw Integration
22

33
This repository contains an OpenClaw plugin under `packages/clawdstrike-openclaw`.
44

55
## Enforcement boundaries (read this)
66

7-
The current OpenClaw plugin enforces policy at the **tool boundary**:
7+
The OpenClaw plugin enforces policy at the **tool boundary**:
88

99
- **Preflight** via the `policy_check` tool (agents should call it before risky operations).
1010
- **Post-action** via the `tool_result_persist` hook (can block/redact what is persisted + record violations).
1111

12-
This is **not** an OS sandbox and does not intercept syscalls. If an agent/runtime bypasses the OpenClaw tool layer, clawdstrike cannot stop it.
12+
This is **not** an OS sandbox and does not intercept syscalls. If an agent/runtime bypasses the OpenClaw tool layer, Clawdstrike cannot stop it.
1313

14-
CI runs an **in-process simulated runtime** E2E (`npm run e2e` in `packages/clawdstrike-openclaw`) to verify wiring/behavior without starting OpenClaw itself.
14+
## Installation
15+
16+
### From local development (alpha)
17+
18+
```bash
19+
# Link the local package
20+
openclaw plugins install --link /path/to/hushclaw/packages/clawdstrike-openclaw
21+
22+
# Enable the plugin
23+
openclaw plugins enable clawdstrike-security
24+
25+
# Verify it's loaded
26+
openclaw plugins list | grep clawdstrike
27+
```
28+
29+
### From npm (when published)
30+
31+
```bash
32+
openclaw plugins install @clawdstrike/clawdstrike-security
33+
```
34+
35+
## Quick verification
36+
37+
```bash
38+
# Check plugin status
39+
openclaw clawdstrike status
40+
41+
# Test policy checks
42+
openclaw clawdstrike check file_read ~/.ssh/id_rsa
43+
# → Denied by forbidden_path
44+
45+
openclaw clawdstrike check file_read /tmp/test.txt
46+
# → Action allowed
47+
48+
# Test with an agent
49+
openclaw agent --local --session-id test \
50+
--message "Use policy_check to check if reading ~/.ssh/id_rsa is allowed"
51+
```
1552

1653
## Important: policy schema is different from Rust
1754

@@ -21,23 +58,70 @@ If you paste a Rust policy into OpenClaw, it should fail closed (and it does): u
2158

2259
See [Schema Governance](../concepts/schema-governance.md) for the repo-wide versioning/compat rules.
2360

61+
## Configuration
62+
63+
Add to `~/.openclaw/openclaw.json`:
64+
65+
```json
66+
{
67+
"plugins": {
68+
"entries": {
69+
"clawdstrike-security": {
70+
"enabled": true,
71+
"config": {
72+
"policy": "./.hush/policy.yaml",
73+
"mode": "deterministic",
74+
"logLevel": "info"
75+
}
76+
}
77+
}
78+
}
79+
}
80+
```
81+
2482
## Recommended flow
2583

26-
- Use a built-in ruleset as a starting point: `clawdstrike:ai-agent-minimal` or `clawdstrike:ai-agent`.
27-
- Validate policies before running agents:
84+
1. Use a built-in ruleset as a starting point: `clawdstrike:ai-agent-minimal` or `clawdstrike:ai-agent`.
2885

29-
```bash
30-
# The OpenClaw plugin ships its own Node CLI named `clawdstrike`.
31-
# Use `npx` to avoid confusion with the deprecated Rust `clawdstrike` binary.
32-
npx clawdstrike policy lint .hush/policy.yaml
86+
2. Test policy checks via CLI:
87+
```bash
88+
openclaw clawdstrike check file_read ~/.ssh/id_rsa
89+
openclaw clawdstrike check network api.github.com
90+
```
91+
92+
3. Use `policy_check` tool for **preflight** decisions (before the agent attempts an action).
93+
94+
4. Use the OpenClaw hook(s) for **post-action** defense-in-depth (e.g., block/strip tool outputs that contain secrets).
95+
96+
## Agent tool: policy_check
97+
98+
The plugin registers a `policy_check` tool that agents can use:
99+
100+
```
101+
policy_check({ action: "file_read", resource: "~/.ssh/id_rsa" })
102+
→ {
103+
"allowed": false,
104+
"denied": true,
105+
"guard": "forbidden_path",
106+
"message": "Denied by forbidden_path: Access to forbidden path...",
107+
"suggestion": "SSH keys are protected..."
108+
}
33109
```
34110

35-
- Use `policy_check` for **preflight** decisions (before the agent attempts an action).
36-
- Use the OpenClaw hook(s) for **post-action** defense-in-depth (e.g., block/strip tool outputs that contain secrets).
111+
**Actions:** `file_read`, `file_write`, `network`, `command`, `tool_call`
112+
113+
## CLI commands
114+
115+
```bash
116+
# Plugin status
117+
openclaw clawdstrike status
118+
119+
# Check an action
120+
openclaw clawdstrike check <action> <resource>
121+
```
37122

38123
## Where to look
39124

40125
- OpenClaw plugin docs: `packages/clawdstrike-openclaw/docs/`
41126
- OpenClaw plugin code: `packages/clawdstrike-openclaw/src/`
42-
- Example (minimal wiring): `examples/hello-secure-agent/`
43-
- Example (agentic EDR triage loop): `examples/bb-edr/`
127+
- Example (minimal wiring): `packages/clawdstrike-openclaw/examples/hello-secure-agent/`

examples/bb-edr/openclaw.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
"plugins": {
2727
"entries": {
28-
"@clawdstrike/openclaw": {
28+
"clawdstrike-security": {
2929
"enabled": true,
3030
"config": {
3131
"policy": "./policy.yaml",

examples/hello-secure-agent/openclaw.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,25 @@
2323
]
2424
},
2525

26-
"plugins": [
27-
{
28-
"name": "@clawdstrike/openclaw",
29-
"version": "^0.1.0",
30-
"config": {
31-
"policy": "./policy.yaml",
32-
"mode": "deterministic",
33-
"logLevel": "info",
34-
"guards": {
35-
"forbidden_path": true,
36-
"egress": true,
37-
"secret_leak": true,
38-
"patch_integrity": true,
39-
"mcp_tool": false
26+
"plugins": {
27+
"entries": {
28+
"clawdstrike-security": {
29+
"enabled": true,
30+
"config": {
31+
"policy": "./policy.yaml",
32+
"mode": "deterministic",
33+
"logLevel": "info",
34+
"guards": {
35+
"forbidden_path": true,
36+
"egress": true,
37+
"secret_leak": true,
38+
"patch_integrity": true,
39+
"mcp_tool": false
40+
}
4041
}
4142
}
4243
}
43-
],
44+
},
4445

4546
"environment": {
4647
"HUSH_LOG_LEVEL": "info"

packages/clawdstrike-openclaw/docs/getting-started.md

Lines changed: 75 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,20 @@ This is **not** an OS sandbox. If an agent/runtime can access the filesystem/net
1313

1414
## Installation
1515

16+
### From local development (recommended during alpha)
17+
18+
```bash
19+
# Link the local package
20+
openclaw plugins install --link /path/to/hushclaw/packages/clawdstrike-openclaw
21+
22+
# Enable the plugin
23+
openclaw plugins enable clawdstrike-security
24+
```
25+
26+
### From npm (when published)
27+
1628
```bash
17-
npm install @clawdstrike/openclaw
18-
openclaw plugins enable @clawdstrike/openclaw
29+
openclaw plugins install @clawdstrike/clawdstrike-security
1930
```
2031

2132
## Quick Start
@@ -46,72 +57,58 @@ on_violation: cancel
4657
4758
### 2. Configure OpenClaw
4859
49-
Add to your `openclaw.json`:
60+
Add to your `~/.openclaw/openclaw.json`:
5061

5162
```json
5263
{
5364
"plugins": {
5465
"entries": {
55-
"@clawdstrike/openclaw": {
66+
"clawdstrike-security": {
5667
"enabled": true,
5768
"config": {
58-
"policy": "./.hush/policy.yaml"
69+
"policy": "./.hush/policy.yaml",
70+
"mode": "deterministic"
5971
}
6072
}
6173
}
6274
}
6375
}
6476
```
6577

66-
### 3. Start OpenClaw
78+
### 3. Restart Gateway (if running)
6779

6880
```bash
69-
openclaw start
81+
openclaw gateway restart
7082
```
7183

7284
Clawdstrike is now configured for your OpenClaw runtime.
7385

7486
## Verify It Works
7587

76-
Ask your agent: "Try to read ~/.ssh/id_rsa" (via whatever file-reading tool OpenClaw provides).
77-
78-
Expected behavior: the tool result should be blocked/redacted and you should see a message indicating the `forbidden_path` guard denied it.
79-
80-
## Using the CLI
81-
82-
### Validate Your Policy
88+
### Using the CLI
8389

8490
```bash
85-
clawdstrike policy lint .hush/policy.yaml
86-
```
91+
# Check plugin status
92+
openclaw clawdstrike status
8793
88-
### Test an Event
94+
# Test a policy check
95+
openclaw clawdstrike check file_read ~/.ssh/id_rsa
96+
# → Denied by forbidden_path: Access to forbidden path...
8997
90-
Create `test-event.json`:
91-
```json
92-
{
93-
"eventId": "example-1",
94-
"eventType": "file_read",
95-
"timestamp": "2026-02-02T00:00:00Z",
96-
"data": { "type": "file", "path": "~/.ssh/id_rsa", "operation": "read" }
97-
}
98+
openclaw clawdstrike check file_read /tmp/test.txt
99+
# → Action allowed
98100
```
99101

100-
```bash
101-
clawdstrike policy test test-event.json --policy .hush/policy.yaml
102-
```
102+
### Using an Agent
103103

104-
### Query Audit Log
104+
Ask your agent to use the policy_check tool:
105105

106106
```bash
107-
clawdstrike audit query --denied
107+
openclaw agent --local --session-id test \
108+
--message "Use policy_check to check if reading ~/.ssh/id_rsa is allowed"
108109
```
109110

110-
### Explain a Block
111-
112-
```bash
113-
clawdstrike why <event-id>
114-
```
111+
Expected: The agent uses `policy_check` and reports that access is denied by the `forbidden_path` guard.
115112

116113
## Agent Tools
117114

@@ -120,15 +117,25 @@ clawdstrike why <event-id>
120117
Agents can use the `policy_check` tool to check permissions before attempting operations:
121118

122119
```
123-
policy_check({ action: "file_write", resource: "/etc/passwd" })
124-
-> { allowed: false, denied: true, warn: false, guard: "forbidden_path", message: "Denied by forbidden_path: …" }
120+
policy_check({ action: "file_read", resource: "~/.ssh/id_rsa" })
121+
→ {
122+
"allowed": false,
123+
"denied": true,
124+
"guard": "forbidden_path",
125+
"message": "Denied by forbidden_path: Access to forbidden path...",
126+
"suggestion": "SSH keys are protected. Consider using a different credential storage method."
127+
}
125128
```
126129

127-
The tool provides:
130+
**Parameters:**
131+
- `action`: One of `file_read`, `file_write`, `network`, `command`, `tool_call`
132+
- `resource`: The resource to check (file path, domain/URL, command string, or tool name)
133+
134+
**Response fields:**
128135
- `allowed`: Whether the action is permitted
129136
- `denied`: Whether the action is blocked
130-
- `reason` / `message`: Human-readable explanation
131137
- `guard`: Which guard made the decision
138+
- `reason` / `message`: Human-readable explanation
132139
- `suggestion`: Helpful alternative approaches
133140

134141
## Policy Reference
@@ -173,7 +180,7 @@ on_violation: cancel # cancel | warn | log
173180

174181
## Built-in Rulesets
175182

176-
Use predefined rulesets by extending them:
183+
Use predefined rulesets:
177184

178185
```yaml
179186
extends: clawdstrike:ai-agent-minimal
@@ -183,7 +190,34 @@ Available rulesets:
183190
- `clawdstrike:ai-agent-minimal` - Basic protection
184191
- `clawdstrike:ai-agent` - Standard development
185192

193+
## Plugin Configuration Options
194+
195+
```json
196+
{
197+
"clawdstrike-security": {
198+
"enabled": true,
199+
"config": {
200+
"policy": "./policy.yaml",
201+
"mode": "deterministic",
202+
"logLevel": "info",
203+
"guards": {
204+
"forbidden_path": true,
205+
"egress": true,
206+
"secret_leak": true,
207+
"patch_integrity": true
208+
}
209+
}
210+
}
211+
}
212+
```
213+
214+
- `policy`: Path to policy YAML or built-in ruleset name
215+
- `mode`: `deterministic` (block), `advisory` (warn), or `audit` (log only)
216+
- `logLevel`: `debug`, `info`, `warn`, or `error`
217+
- `guards`: Enable/disable specific guards
218+
186219
## Next Steps
187220

188221
- Check the [Examples](../examples/) directory
189-
- Run `clawdstrike --help` to explore the plugin CLI surface
222+
- Run `openclaw clawdstrike --help` to explore CLI commands
223+
- See the main [Clawdstrike documentation](../../../../docs/src/reference/guards/README.md) for guard details

packages/clawdstrike-openclaw/examples/hello-secure-agent/openclaw.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"plugins": {
33
"entries": {
4-
"@clawdstrike/openclaw": {
4+
"clawdstrike-security": {
55
"enabled": true,
66
"config": {
77
"policy": "./policy.yaml",

0 commit comments

Comments
 (0)