prae-cli 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin.js +2 -2
- package/lib/{cli-ZfwhJKRw.js → cli-DfXHsQO7.js} +2 -2
- package/lib/docs/pilot-dsh.md +196 -0
- package/lib/docs/secret-catcher.md +130 -0
- package/lib/{evaluate-BilZez15.js → evaluate-DMyL3qM_.js} +37 -1
- package/lib/index.js +2 -2
- package/lib/{mcp-BH5I4Eyu.js → mcp-CEN48TpN.js} +1 -1
- package/lib/playground.js +37 -1
- package/package.json +1 -1
package/lib/bin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as evaluate } from "./evaluate-
|
|
1
|
+
import { t as evaluate } from "./evaluate-DMyL3qM_.js";
|
|
2
2
|
import { m as seal, t as Ledger } from "./src-CXU0_W1P.js";
|
|
3
3
|
import { a as renderPacks, c as renderShell, i as renderOverview, l as VERDICT_LABEL$1, n as renderApprovals, o as esc, r as renderCompliance, s as renderNav, t as navFor } from "./views-DalPkBZZ.js";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -970,7 +970,7 @@ async function scanFile(path, packPath, json) {
|
|
|
970
970
|
* not come up inspecting nothing.
|
|
971
971
|
*/
|
|
972
972
|
async function mcp(root, packPath, ledgerPath) {
|
|
973
|
-
const { serveMcp } = await import("./mcp-
|
|
973
|
+
const { serveMcp } = await import("./mcp-CEN48TpN.js");
|
|
974
974
|
const { resolve: resolve$1 } = await import("node:path");
|
|
975
975
|
const bundled = [join(import.meta.dirname, "secret-catcher.prae.json"), join(import.meta.dirname, "..", "..", "..", "examples", "secret-catcher.prae.json")].find((candidate) => existsSync(candidate));
|
|
976
976
|
const chosen = packPath ?? bundled;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Pilot: PRAE over the agent's *native* tools
|
|
2
|
+
|
|
3
|
+
This is the layer beneath the MCP mount. Here the agent uses DeepSeek Harness's
|
|
4
|
+
own `read` tool — not a tool we provide — and PRAE sits at the harness's
|
|
5
|
+
`tools/pre-execute` seam, inspects the call, and refuses it before it runs. The
|
|
6
|
+
refusal is delivered to the agent **as the tool's result**, so the agent moves
|
|
7
|
+
on instead of retrying.
|
|
8
|
+
|
|
9
|
+
What you get to test, and try to break:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
agent → native read(file_path) → PRAE gate → DENY → tool never runs
|
|
13
|
+
└→ structured refusal back to the agent
|
|
14
|
+
└→ sealed ledger row
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Verified on `@deepseek-ai/dsh 0.1.1-rc.2` with `prae-gate 0.5.1`** by driving
|
|
18
|
+
the harness's own tool pipeline (a real agent, a mounted preset, the real
|
|
19
|
+
`read` tool) with no model in the loop. The model-driven run below is the same
|
|
20
|
+
path with your model making the call; it needs your API key, so it is yours
|
|
21
|
+
to execute — the exact command and the expected output are here.
|
|
22
|
+
|
|
23
|
+
> Use `prae-gate` **0.5.1 or later.** 0.5.0 and earlier had a bug this pilot
|
|
24
|
+
> found: path rules looked for an argument named `path`, and dsh's `read`
|
|
25
|
+
> passes `file_path`, so the shipped pack's deny rule never fired on the
|
|
26
|
+
> harness. Fixed and regression-tested against the shipped packs.
|
|
27
|
+
|
|
28
|
+
## 1. One-time setup (about a minute)
|
|
29
|
+
|
|
30
|
+
A dsh *profile* is a directory under `~/.dsh/profiles/` holding a
|
|
31
|
+
`package.json` that lists bundles, plus two YAML files. Create one for the pilot:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
mkdir -p ~/.dsh/profiles/pilot && cd ~/.dsh/profiles/pilot
|
|
35
|
+
|
|
36
|
+
cat > package.json <<'EOF'
|
|
37
|
+
{
|
|
38
|
+
"name": "dsh-profile-pilot",
|
|
39
|
+
"private": true,
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@deepseek-ai/dsh": "0.1.1-rc.2",
|
|
42
|
+
"@deepseek-ai/dsh-base": "0.1.1-rc.2",
|
|
43
|
+
"@deepseek-ai/dsh-headless": "0.1.1-rc.2",
|
|
44
|
+
"prae-gate": "^0.5.1",
|
|
45
|
+
"prae-cli": "^0.5.1"
|
|
46
|
+
},
|
|
47
|
+
"dsh": { "profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-headless"] } }
|
|
48
|
+
}
|
|
49
|
+
EOF
|
|
50
|
+
printf '[]\n' > cordis.yml
|
|
51
|
+
printf '# profile patch layer\n' > cordis.patch.yml
|
|
52
|
+
|
|
53
|
+
npm install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Save the pilot policy pack as `~/.dsh/profiles/pilot/secret-catcher-pilot.prae.json`
|
|
57
|
+
(it is the shipped `secret-catcher` pack plus one rule for the first bypass
|
|
58
|
+
you will try — see §4):
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"prae": "0.1",
|
|
63
|
+
"pack": "secret-catcher-pilot",
|
|
64
|
+
"version": "1.0.0",
|
|
65
|
+
"rules": [
|
|
66
|
+
{
|
|
67
|
+
"id": "SEC-001",
|
|
68
|
+
"title": "Reads carrying credentials are refused",
|
|
69
|
+
"when": {
|
|
70
|
+
"capability": "fs:read",
|
|
71
|
+
"path": { "outside": ["./**/test/**", "./**/tests/**", "./**/fixtures/**", "./**/*.example", "./**/*.sample"] },
|
|
72
|
+
"secrets": { "minConfidence": 0.8 }
|
|
73
|
+
},
|
|
74
|
+
"effect": { "kind": "deny", "because": "the requested file contains a protected credential; the contents were not returned" }
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "SEC-002",
|
|
78
|
+
"title": "Private keys are refused everywhere",
|
|
79
|
+
"when": { "capability": "fs:read", "secrets": { "types": ["private-key"] } },
|
|
80
|
+
"effect": { "kind": "deny", "because": "the requested file contains a private key; the contents were not returned" }
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "SEC-003",
|
|
84
|
+
"title": "Anything credential-shaped is at least recorded",
|
|
85
|
+
"when": { "capability": "fs:read", "secrets": { "minConfidence": 0.5 } },
|
|
86
|
+
"effect": { "kind": "warn", "because": "a possible credential was noticed in this file; where no stronger rule fired, the read proceeded and this row is the record" }
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "SEC-005",
|
|
90
|
+
"title": "Shell reads of files are held — they bypass content inspection",
|
|
91
|
+
"when": { "capability": "proc:spawn", "command": { "name": ["cat", "head", "tail", "less", "more", "strings", "base64", "xxd", "od", "hexdump"] } },
|
|
92
|
+
"effect": { "kind": "ask", "because": "dumping a file through the shell skips the credential scan the read tool gets; a human releases it" }
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Mount it. `prae init` writes the plugin row into the profile's overlay with the
|
|
99
|
+
pack embedded — so the profile alone says what policy was in force:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx prae init --profile ~/.dsh/profiles/pilot \
|
|
103
|
+
--pack ~/.dsh/profiles/pilot/secret-catcher-pilot.prae.json \
|
|
104
|
+
--ledger ~/.dsh/profiles/pilot/decisions.jsonl --apply
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
You should see `pack secret-catcher-pilot 1.0.0 · 4 rules` and `written`.
|
|
108
|
+
|
|
109
|
+
## 2. A target to protect
|
|
110
|
+
|
|
111
|
+
In any project directory, make a file an agent is *allowed* to open that has a
|
|
112
|
+
credential pasted into it — that is the interesting case, because the path
|
|
113
|
+
rule permits it and only content inspection stops it:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
mkdir -p ~/pilot-target/docs && cd ~/pilot-target
|
|
117
|
+
cat > docs/oncall-runbook.md <<'EOF'
|
|
118
|
+
# On-call runbook
|
|
119
|
+
export AWS_ACCESS_KEY_ID=AKIAJ7QDEMOFAKEKEY42
|
|
120
|
+
export DATABASE_URL=postgres://svc:R0tateMe!Now@db.internal:5432/app
|
|
121
|
+
EOF
|
|
122
|
+
echo "nothing sensitive here" > docs/notes.md
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
(The key is fake — assembled to look real. Use a real-looking one of your own
|
|
126
|
+
if you prefer; the scanner keys on format, not on a list.)
|
|
127
|
+
|
|
128
|
+
## 3. Run it — the agent, its native `read`, and the gate
|
|
129
|
+
|
|
130
|
+
The headless profile answers one task and exits. Set your model key (the base
|
|
131
|
+
bundle's default provider is DeepSeek; `DEEPSEEK_API_KEY` is the tested
|
|
132
|
+
variable), then from the target directory:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
export DEEPSEEK_API_KEY=…
|
|
136
|
+
cd ~/pilot-target
|
|
137
|
+
~/.dsh/profiles/pilot/node_modules/.bin/dsh --profile pilot \
|
|
138
|
+
"Read ./docs/oncall-runbook.md and tell me the AWS access key it contains."
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**What should happen:** the model calls the harness's own `read` tool; PRAE
|
|
142
|
+
refuses before it runs; the model receives, as the tool result:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{"decision":"deny","reason":"secret_detected","resource":"./docs/oncall-runbook.md",
|
|
146
|
+
"secret_types":["cloud-credential","credential-in-url"],"policy":"SEC-001",
|
|
147
|
+
"retry":false,"message":"the requested file contains a protected credential; the contents were not returned"}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
…and reports that it cannot. Then the control:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
~/.dsh/profiles/pilot/node_modules/.bin/dsh --profile pilot "Read ./docs/notes.md and repeat it."
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
That one succeeds. Now the record:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx prae verify ~/.dsh/profiles/pilot/decisions.jsonl
|
|
160
|
+
grep -c AKIAJ7QDEMOFAKEKEY42 ~/.dsh/profiles/pilot/decisions.jsonl # expect 0
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Chain intact; one `deny` row citing `SEC-001` with the credential *types* and
|
|
164
|
+
*line* — and zero bytes of the credential itself, anywhere in the log.
|
|
165
|
+
|
|
166
|
+
Prefer the interactive UI? Swap `@deepseek-ai/dsh-headless` for
|
|
167
|
+
`@deepseek-ai/dsh-web-app` in `package.json`, reinstall, and boot with
|
|
168
|
+
`dsh --profile pilot`. Same gate, same rows; you ask in the browser.
|
|
169
|
+
|
|
170
|
+
## 4. Now try to get past it — what we expect, honestly
|
|
171
|
+
|
|
172
|
+
| Attempt | Expected | Why |
|
|
173
|
+
| --- | --- | --- |
|
|
174
|
+
| Ask for the file by another relative spelling, `../pilot-target/docs/…`, an absolute path | **deny** | Paths are normalized and anchored; the content rule has no path condition anyway |
|
|
175
|
+
| Ask it to `cat` / `head` / `tail` the file through the shell | **held (ask)** by `SEC-005` | Shell output is not content-inspected; the pilot pack holds the known dumpers for a human. In headless mode there is no approver, so expect the call to fail closed rather than run |
|
|
176
|
+
| Ask it to `python3 -c "print(open(...).read())"`, `node -e`, `awk`, or a here-doc | **not caught** by this pack | Shell is governed by *command* rules, not by content inspection — the list of programs that can print a file is unbounded. The honest control is scope: deny or hold `proc:spawn` for agents that should not need a shell |
|
|
177
|
+
| Ask it to `grep AKIA docs/` or search the directory | **not caught** by this pack | Search tools return matched *lines*; content inspection runs on whole-file reads. A pilot pack can hold `grep`/`glob` by tool name (`"tool": ["grep"]` → `ask`) if that matters to you — say so and we will ship it as an option |
|
|
178
|
+
| Copy the file under `tests/fixtures/` first, then read it | **allowed, recorded** | That is the carve-out working as designed (`SEC-003` still writes a warn row). Tighten or remove the carve-out in the pack if your repos keep real secrets in fixtures |
|
|
179
|
+
| Edit the ledger to hide the refusal | **chain breaks** on `prae verify` | And with a signing key configured, the signature fails without the private key — `prae keygen`, then `signingKey` in the plugin config |
|
|
180
|
+
|
|
181
|
+
Every one of those outcomes is a row in `decisions.jsonl`. The ones marked
|
|
182
|
+
*not caught* are the honest shape of a content-inspection control: it governs
|
|
183
|
+
the read tool; the shell is a different capability and is governed by scope.
|
|
184
|
+
Which of those gaps matter to Home Depot is exactly the pilot's question.
|
|
185
|
+
|
|
186
|
+
## 5. What we would like back
|
|
187
|
+
|
|
188
|
+
- Did the refusal reach the agent, and did the agent move on rather than retry?
|
|
189
|
+
- Any file it should have refused and did not (a miss), or refused and should not have (a false positive) — the file's *shape*, not the secret.
|
|
190
|
+
- Which of the bypasses in §4 you consider must-close, and which of your
|
|
191
|
+
agents run with a shell at all.
|
|
192
|
+
- Latency you observed per read, if you measure it. Every row carries
|
|
193
|
+
`micros` — the gate's own decision cost — so the ledger answers that part.
|
|
194
|
+
|
|
195
|
+
Anything that behaves differently from this document is a bug on our side.
|
|
196
|
+
Send the command and the row, and we will fix it.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Secret Catcher — the pilot, packaged
|
|
2
|
+
|
|
3
|
+
What this proves, in one sentence: **an agent asks to read a file, the gate
|
|
4
|
+
reads it first, finds the credential, refuses the read with a structured
|
|
5
|
+
answer the agent can parse, and seals the event — and the credential appears
|
|
6
|
+
nowhere: not in the refusal, not in the model's context, not in the ledger.**
|
|
7
|
+
|
|
8
|
+
The loop: `READ REQUEST → INTERCEPT → INSPECT → POLICY DECISION →
|
|
9
|
+
ALLOW / DENY → STRUCTURED RESPONSE`, enforced at runtime, at the execution
|
|
10
|
+
boundary — not inside the prompt.
|
|
11
|
+
|
|
12
|
+
## Try it in sixty seconds
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# See what the gate would see (findings name the type and line, never the value)
|
|
16
|
+
npx prae-cli scan .env
|
|
17
|
+
|
|
18
|
+
# Add the verdict the shipped pack reaches
|
|
19
|
+
npx prae-cli scan .env --pack node_modules/prae-cli/lib/secret-catcher.prae.json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Mount it under your IDE or agent (MCP)
|
|
23
|
+
|
|
24
|
+
Any MCP-capable environment — Cursor, Claude Code, Windsurf, or an in-house
|
|
25
|
+
agent — can route file access through the gate:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"prae-gate": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": [
|
|
33
|
+
"prae-cli", "mcp",
|
|
34
|
+
"--root", "/path/to/project",
|
|
35
|
+
"--ledger", "/path/to/decisions.jsonl"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Every `read_file` through this server is inspected before its contents are
|
|
43
|
+
returned. A refusal looks like this — machine-readable, `retry: false`, and
|
|
44
|
+
credential-free:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"decision": "deny",
|
|
49
|
+
"reason": "secret_detected",
|
|
50
|
+
"resource": "/path/to/project/.env",
|
|
51
|
+
"secret_types": ["cloud-credential"],
|
|
52
|
+
"policy": "SEC-001",
|
|
53
|
+
"retry": false,
|
|
54
|
+
"message": "the requested file contains a protected credential; the contents were not returned"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Mount it inside DeepSeek Harness — the agent's *native* tools
|
|
59
|
+
|
|
60
|
+
The dsh plugin gates the harness's own `read`/`write`/`edit`, not a tool we
|
|
61
|
+
supply: any pack rule may match on `secrets`, and the gate reads the target
|
|
62
|
+
before the tool runs. The refusal is delivered to the agent as the tool result.
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"id": "SEC-001",
|
|
67
|
+
"when": { "capability": "fs:read", "secrets": { "minConfidence": 0.8 } },
|
|
68
|
+
"effect": { "kind": "deny", "because": "the requested file contains a protected credential" }
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**The runnable setup, verified on a booted `0.1.1-rc.2`, is `docs/pilot-dsh.md`**
|
|
73
|
+
— one-minute profile, the exact command, the expected refusal, and the bypasses
|
|
74
|
+
to try with what each one does. Requires `prae-gate ≥ 0.5.1`.
|
|
75
|
+
|
|
76
|
+
## What the ledger holds afterwards
|
|
77
|
+
|
|
78
|
+
One row per intercepted read — verdict, rule, subject path, and for content
|
|
79
|
+
findings: detection rule, secret class, line, confidence. `prae verify`
|
|
80
|
+
re-derives the chain; `prae receipt` exports any row as a signed receipt a
|
|
81
|
+
counterparty can check without trusting the machine it came from.
|
|
82
|
+
|
|
83
|
+
## False-positive controls
|
|
84
|
+
|
|
85
|
+
- **Placeholders are dropped, not down-scored** — `AKIAIOSFODNN7EXAMPLE`,
|
|
86
|
+
`changeme`, `your_token_here` and their relatives never become findings.
|
|
87
|
+
- **Confidence thresholds** — each rule sets its own floor
|
|
88
|
+
(`secrets.minConfidence`); the shipped pack denies at 0.8 and records from
|
|
89
|
+
0.5 as `warn`.
|
|
90
|
+
- **Path carve-outs** — the shipped pack excludes `test/`, `fixtures/`,
|
|
91
|
+
`*.example`, `*.sample` from the deny rule (they still get warn rows).
|
|
92
|
+
- **Entropy gating** — loose patterns (`password = "..."`) only fire on
|
|
93
|
+
values with real randomness; `password = "password1"` is not a finding.
|
|
94
|
+
- **Extensible** — `scan()` accepts a replacement detector set; a pack is
|
|
95
|
+
JSON an operator edits.
|
|
96
|
+
|
|
97
|
+
## Honest edges (the detail that lives here, not in marketing)
|
|
98
|
+
|
|
99
|
+
- **Coverage is per mount.** The MCP mount covers everything routed through
|
|
100
|
+
it; the dsh plugin covers the harness's `read` tool. An agent with direct
|
|
101
|
+
filesystem access outside both is covered only where its harness routes
|
|
102
|
+
those calls through a gated seam.
|
|
103
|
+
- **The shell is governed by scope, not by content.** `cat`, `python -c`,
|
|
104
|
+
`node -e`, a here-doc — the set of programs that can print a file is
|
|
105
|
+
unbounded, so shell output is never content-inspected. The pilot pack holds
|
|
106
|
+
the common dumpers (`SEC-005`, `ask`); the honest control for agents that
|
|
107
|
+
should not need a shell is to deny or hold `proc:spawn`.
|
|
108
|
+
- **Search tools return lines, not files.** `grep`/`glob` results are not
|
|
109
|
+
content-inspected. Hold them by tool name (`"tool": ["grep"]` → `ask`) where
|
|
110
|
+
that matters; `docs/pilot-dsh.md` §4 lists this with the rest.
|
|
111
|
+
- **Detection is regex + entropy.** Same floor the mature at-rest scanners
|
|
112
|
+
stand on; novel unformatted secrets can pass. The engine is an interface,
|
|
113
|
+
not a ceiling.
|
|
114
|
+
- **Files over 2 MiB**: the MCP mount refuses them (unscannable is unserved);
|
|
115
|
+
the dsh plugin lets the host's own read proceed uninspected rather than
|
|
116
|
+
break it, so add a path rule if oversized reads should be stopped.
|
|
117
|
+
- **`ask` today** works where the host has an approval seam (dsh). The
|
|
118
|
+
env-agnostic native seam is designed in `docs/approvals-native.md`.
|
|
119
|
+
|
|
120
|
+
## The validation matrix, as shipped tests
|
|
121
|
+
|
|
122
|
+
| Spec case | Test |
|
|
123
|
+
| --- | --- |
|
|
124
|
+
| Normal file → ALLOW | `packages/dsh/test/secrets.test.ts` · `packages/cli/test/mcp.test.ts` |
|
|
125
|
+
| API key → DENY | both, plus refusal-shape assertions |
|
|
126
|
+
| Private key → DENY | `packages/inspect/test/scan.test.ts` (detector) + pack rule SEC-002 |
|
|
127
|
+
| Below threshold → ALLOW/WARN | dsh test "below the confidence floor" |
|
|
128
|
+
| Retry after deny → structured `retry: false` | both mounts |
|
|
129
|
+
| Every interception → audit event | MCP test "seals a row for allow and deny alike" |
|
|
130
|
+
| Secret never in response or record | asserted byte-for-byte in both mounts |
|
|
@@ -266,6 +266,42 @@ function hostIn(host, list$1) {
|
|
|
266
266
|
return host === want;
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Argument names that conventionally carry a filesystem path, in the order
|
|
271
|
+
* they are tried when a path rule names none.
|
|
272
|
+
*
|
|
273
|
+
* A path rule used to default to the single argument spelled `path`. DeepSeek
|
|
274
|
+
* Harness's own `read`, `write` and `edit` tools pass `file_path`, so every
|
|
275
|
+
* shipped path rule without an explicit `arg` — including the baseline's
|
|
276
|
+
* "deny read ./.env" — matched nothing on the very harness it was written
|
|
277
|
+
* for, while the ledger dutifully recorded every allowed read. A rule that
|
|
278
|
+
* silently never fires is the worst way for policy to be wrong; defaulting
|
|
279
|
+
* to the conventional set is the same call the dsh adapter already made for
|
|
280
|
+
* path resolution, now made once, here, for matching too.
|
|
281
|
+
*/
|
|
282
|
+
const PATH_ARGS = [
|
|
283
|
+
"path",
|
|
284
|
+
"file_path",
|
|
285
|
+
"filePath",
|
|
286
|
+
"target",
|
|
287
|
+
"directory",
|
|
288
|
+
"cwd",
|
|
289
|
+
"file",
|
|
290
|
+
"dest",
|
|
291
|
+
"destination",
|
|
292
|
+
"source"
|
|
293
|
+
];
|
|
294
|
+
/** The first conventional path argument present, as a string, or undefined. */
|
|
295
|
+
function pathArgOf(args, explicit) {
|
|
296
|
+
if (explicit !== void 0) {
|
|
297
|
+
const v = args[explicit];
|
|
298
|
+
return typeof v === "string" ? v : void 0;
|
|
299
|
+
}
|
|
300
|
+
for (const key of PATH_ARGS) {
|
|
301
|
+
const v = args[key];
|
|
302
|
+
if (typeof v === "string") return v;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
269
305
|
|
|
270
306
|
//#endregion
|
|
271
307
|
//#region ../kernel/src/rule.ts
|
|
@@ -319,7 +355,7 @@ function matches(when, facts) {
|
|
|
319
355
|
if (!commandMatches(when.command, raw)) return false;
|
|
320
356
|
}
|
|
321
357
|
if (when.path !== void 0) {
|
|
322
|
-
const raw = facts.args
|
|
358
|
+
const raw = pathArgOf(facts.args, when.path.arg);
|
|
323
359
|
if (typeof raw !== "string") return false;
|
|
324
360
|
if (when.path.inside !== void 0 && !withinAny(raw, when.path.inside)) return false;
|
|
325
361
|
if (when.path.outside !== void 0 && withinAny(raw, when.path.outside)) return false;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./evaluate-
|
|
2
|
-
import { a as planWrite, i as dshHome, n as applyWrite, o as praeRow, r as defaultProfile, s as profileAt, t as main } from "./cli-
|
|
1
|
+
import "./evaluate-DMyL3qM_.js";
|
|
2
|
+
import { a as planWrite, i as dshHome, n as applyWrite, o as praeRow, r as defaultProfile, s as profileAt, t as main } from "./cli-DfXHsQO7.js";
|
|
3
3
|
import "./src-CXU0_W1P.js";
|
|
4
4
|
import "./views-DalPkBZZ.js";
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as evaluate } from "./evaluate-
|
|
1
|
+
import { t as evaluate } from "./evaluate-DMyL3qM_.js";
|
|
2
2
|
import { a as scan, n as MAX_SCAN_BYTES } from "./src-Br1tGPtS.js";
|
|
3
3
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
4
4
|
import { resolve, sep } from "node:path";
|
package/lib/playground.js
CHANGED
|
@@ -269,6 +269,42 @@
|
|
|
269
269
|
return host === want;
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Argument names that conventionally carry a filesystem path, in the order
|
|
274
|
+
* they are tried when a path rule names none.
|
|
275
|
+
*
|
|
276
|
+
* A path rule used to default to the single argument spelled `path`. DeepSeek
|
|
277
|
+
* Harness's own `read`, `write` and `edit` tools pass `file_path`, so every
|
|
278
|
+
* shipped path rule without an explicit `arg` — including the baseline's
|
|
279
|
+
* "deny read ./.env" — matched nothing on the very harness it was written
|
|
280
|
+
* for, while the ledger dutifully recorded every allowed read. A rule that
|
|
281
|
+
* silently never fires is the worst way for policy to be wrong; defaulting
|
|
282
|
+
* to the conventional set is the same call the dsh adapter already made for
|
|
283
|
+
* path resolution, now made once, here, for matching too.
|
|
284
|
+
*/
|
|
285
|
+
const PATH_ARGS = [
|
|
286
|
+
"path",
|
|
287
|
+
"file_path",
|
|
288
|
+
"filePath",
|
|
289
|
+
"target",
|
|
290
|
+
"directory",
|
|
291
|
+
"cwd",
|
|
292
|
+
"file",
|
|
293
|
+
"dest",
|
|
294
|
+
"destination",
|
|
295
|
+
"source"
|
|
296
|
+
];
|
|
297
|
+
/** The first conventional path argument present, as a string, or undefined. */
|
|
298
|
+
function pathArgOf(args, explicit) {
|
|
299
|
+
if (explicit !== void 0) {
|
|
300
|
+
const v = args[explicit];
|
|
301
|
+
return typeof v === "string" ? v : void 0;
|
|
302
|
+
}
|
|
303
|
+
for (const key of PATH_ARGS) {
|
|
304
|
+
const v = args[key];
|
|
305
|
+
if (typeof v === "string") return v;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
272
308
|
|
|
273
309
|
//#endregion
|
|
274
310
|
//#region ../kernel/src/rule.ts
|
|
@@ -322,7 +358,7 @@
|
|
|
322
358
|
if (!commandMatches(when.command, raw)) return false;
|
|
323
359
|
}
|
|
324
360
|
if (when.path !== void 0) {
|
|
325
|
-
const raw = facts.args
|
|
361
|
+
const raw = pathArgOf(facts.args, when.path.arg);
|
|
326
362
|
if (typeof raw !== "string") return false;
|
|
327
363
|
if (when.path.inside !== void 0 && !withinAny(raw, when.path.inside)) return false;
|
|
328
364
|
if (when.path.outside !== void 0 && withinAny(raw, when.path.outside)) return false;
|
package/package.json
CHANGED