@arcforge/types 2.0.168 → 2.0.170
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/package.json +1 -1
- package/src/policy-shell.ts +31 -4
package/package.json
CHANGED
package/src/policy-shell.ts
CHANGED
|
@@ -115,19 +115,46 @@ export function decideShell(
|
|
|
115
115
|
|
|
116
116
|
const { program, shell: isShell } = resolveProgram(argv)
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
/**
|
|
119
|
+
* A shell turns one grant into arbitrary execution. Gated on its own switch
|
|
120
|
+
* so `allow: ["git"]` cannot be quietly widened by `sh` being on the box.
|
|
121
|
+
*
|
|
122
|
+
* ESCALATES rather than denying when `raw` is simply unset. `raw: false`
|
|
123
|
+
* is still an absolute refusal — a user who wrote it said no — but silence
|
|
124
|
+
* is not a decision, and a hard deny here bricked the common case: every
|
|
125
|
+
* `process.run(...)` goes through `/bin/sh -c`, so an agent with no shell
|
|
126
|
+
* policy could not run a single command and the error named a rule its
|
|
127
|
+
* author had never written. Asking is the honest answer to a question
|
|
128
|
+
* nobody has answered, and the prompt can say what a shell actually is.
|
|
129
|
+
*/
|
|
120
130
|
if (isShell && shell.raw !== true) {
|
|
121
|
-
return { verdict: "deny", program, reason: "raw-shell" }
|
|
131
|
+
if (shell.raw === false) return { verdict: "deny", program, reason: "raw-shell" }
|
|
132
|
+
return { verdict: "escalate", program, reason: "raw-shell" }
|
|
122
133
|
}
|
|
123
134
|
|
|
135
|
+
// Deny always beats allow, and always means DENY: this one is a rule
|
|
136
|
+
// somebody wrote, naming this program. There is nothing to ask about.
|
|
124
137
|
if (shell.deny?.some(pattern => policyGlobMatch(pattern, program))) {
|
|
125
138
|
return { verdict: "deny", program, reason: "denied" }
|
|
126
139
|
}
|
|
127
140
|
|
|
128
141
|
if (shell.allow !== undefined) {
|
|
142
|
+
/**
|
|
143
|
+
* An allowlist that names nothing matching ESCALATES.
|
|
144
|
+
*
|
|
145
|
+
* It used to be a flat denial, on the "declared, matched nothing" rule
|
|
146
|
+
* the glob resolver uses. That rule is right for a resolver and wrong
|
|
147
|
+
* here: `allow: ["git"]` states that git is permitted and says nothing
|
|
148
|
+
* whatsoever about `axon`, and reading its silence as a refusal left a
|
|
149
|
+
* user with no way forward but to go and edit a config file — the
|
|
150
|
+
* moment a new user gives up and uses something else.
|
|
151
|
+
*
|
|
152
|
+
* Escalation is what the ceiling is FOR. The prompt names the program,
|
|
153
|
+
* and answering "always" writes the grant the user would have gone
|
|
154
|
+
* looking for.
|
|
155
|
+
*/
|
|
129
156
|
const admitted = shell.allow.some(pattern => policyGlobMatch(pattern, program))
|
|
130
|
-
if (!admitted) return { verdict: "
|
|
157
|
+
if (!admitted) return { verdict: "escalate", program, reason: "not-allowed" }
|
|
131
158
|
}
|
|
132
159
|
|
|
133
160
|
// Argument patterns — advisory, and only consulted once the program itself
|