@jackice/pi-approval-gate 0.1.3 → 0.1.4
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/CHANGELOG.md +22 -18
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/bash-hook.ts +2 -2
- package/src/binding.ts +2 -2
- package/src/dialog.ts +1 -1
- package/src/gate.ts +3 -3
- package/src/policy.ts +2 -2
- package/src/uv-guard.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
- English code comments, changelog, and review notes. No behavior change.
|
|
6
|
+
|
|
3
7
|
## 0.1.3
|
|
4
8
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
9
|
+
- Built-in optional uv command guard (`--approval-guard uv` or `approvalGate.guard: "uv"`), off by default.
|
|
10
|
+
- Removed the `guard`/`sourcePath` host options: the package registers `bash` itself, so no second extension is needed.
|
|
7
11
|
|
|
8
12
|
## 0.1.2
|
|
9
13
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
+
- Hardened the native approval view: keeps soft-wrap spaces, escapes invisible characters, shows risk and page status on narrow screens, and refuses approval when the view is clipped.
|
|
15
|
+
- The native selection list is now the default approval UI; `--approval-ui panel` switches back to the styled panel.
|
|
16
|
+
- Added `guard` and `sourcePath` options so a host extension can own the single `bash` registration and reuse approval; `guard` ran before the dialog.
|
|
17
|
+
- `glab mr merge/close` now counts as a remote write.
|
|
14
18
|
|
|
15
19
|
## 0.1.1
|
|
16
20
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- M1/M2/M3/M4/M5
|
|
22
|
-
- L1/L3/L4/L6
|
|
23
|
-
- 66
|
|
21
|
+
- Added `--approval-ui native`: the Pi native selection list replaces the styled panel while keeping default-deny, the arming delay, and Gate decisions.
|
|
22
|
+
- Pinned `@jackice/pi-ui` as a runtime dependency so the candidate extension still loads when Pi omits peer installs.
|
|
23
|
+
- Verify the `bash` registration source by real file path so symlinked installs do not block their own tool; refuse when the source cannot be confirmed.
|
|
24
|
+
- Security review C1/H1/H2/H3: linear quote-aware policy, recursive wrapper parsing, fail-closed behavior, git/gh global options, fullscreen paging.
|
|
25
|
+
- M1/M2/M3/M4/M5: removed the superlinear regex, inherited the shell prefix, intercepted `user_bash`, bidi cleanup, shadow-registration self-check.
|
|
26
|
+
- L1/L3/L4/L6: fingerprint cleanup on close, `maxCommandLines` fallback, paging keys, config clamp.
|
|
27
|
+
- 66 tests; real TUI/fullscreen/user_bash/RPC/subagent verification.
|
|
24
28
|
|
|
25
29
|
## 0.1.0
|
|
26
30
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
- RPC/headless
|
|
31
|
-
-
|
|
31
|
+
- Added ApprovalGate: FIFO queue, 120s timeout, idempotent abort/shutdown cancellation, up to 16 pending requests.
|
|
32
|
+
- Replaced the `bash` execution boundary: after approval a one-shot command+cwd fingerprint is written and consumed by the spawn hook.
|
|
33
|
+
- Added the `ApprovalView` dialog: full command, cwd, reason, risk, Allow once/Deny, scrolling, 500ms arm.
|
|
34
|
+
- RPC/headless/subagent requests are denied by default.
|
|
35
|
+
- Verified default denial on real Pi RPC and with `PI_SUBAGENT_CHILD=1`.
|
package/index.ts
CHANGED
|
@@ -49,7 +49,7 @@ export default function approvalGateExtension(pi: ExtensionAPI): void {
|
|
|
49
49
|
...(pi.getFlag("approval-ui") === "panel" ? {} : { ui: "native" as const }),
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
/**
|
|
52
|
+
/** Resolved per call: flags and settings are only readable after the extension loads. */
|
|
53
53
|
const commandGuard = (): CommandGuard | undefined => {
|
|
54
54
|
if (pi.getFlag("approval-guard") === "uv") return uvGuard;
|
|
55
55
|
const settings = pi.getSettings() as { approvalGate?: { guard?: unknown } } | undefined;
|
package/package.json
CHANGED
package/src/bash-hook.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { verifyFinalBinding } from "./binding.ts";
|
|
|
4
4
|
import type { ApprovalAuthorization, ApprovalRequest } from "./gate.ts";
|
|
5
5
|
|
|
6
6
|
export interface BashGuardOptions {
|
|
7
|
-
/**
|
|
7
|
+
/** Returns a message to block the command; runs before the approval is consumed. */
|
|
8
8
|
guard?: ((command: string) => string | undefined) | undefined;
|
|
9
9
|
authorization?: ApprovalAuthorization | undefined;
|
|
10
10
|
request?: ApprovalRequest | undefined;
|
|
@@ -12,7 +12,7 @@ export interface BashGuardOptions {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Combines the command guard with final approval binding for a Bash spawn hook.
|
|
16
16
|
*/
|
|
17
17
|
export function createBashSpawnHook(options: BashGuardOptions): BashSpawnHook {
|
|
18
18
|
return (context: BashSpawnContext): BashSpawnContext => {
|
package/src/binding.ts
CHANGED
|
@@ -4,8 +4,8 @@ import type { ApprovalAuthorization, ApprovalRequest } from "./gate.ts";
|
|
|
4
4
|
import { isDangerousBash } from "./policy.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Verifies the final command and working directory right before spawn.
|
|
8
|
+
* Dangerous commands must consume an approval bound to this exact call.
|
|
9
9
|
*/
|
|
10
10
|
export function verifyFinalBinding(
|
|
11
11
|
authorization: ApprovalAuthorization | undefined,
|
package/src/dialog.ts
CHANGED
package/src/gate.ts
CHANGED
|
@@ -65,8 +65,8 @@ export function fingerprint(command: string, cwd: string): string {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* Single-writer approval queue. Timeout, abort, and shutdown share one idempotent
|
|
69
|
+
* settle path and never depend on the custom<T> promise settling.
|
|
70
70
|
*/
|
|
71
71
|
export class ApprovalGate {
|
|
72
72
|
private readonly timeoutMs: number | (() => number);
|
|
@@ -204,7 +204,7 @@ export class ApprovalGate {
|
|
|
204
204
|
try {
|
|
205
205
|
entry.cancelPrompt?.();
|
|
206
206
|
} catch {
|
|
207
|
-
//
|
|
207
|
+
// The host component may be gone; settling must not depend on closing the UI.
|
|
208
208
|
}
|
|
209
209
|
if (this.active === entry) this.active = undefined;
|
|
210
210
|
const index = this.queue.indexOf(entry);
|
package/src/policy.ts
CHANGED
|
@@ -32,8 +32,8 @@ function basename(value: string): string {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* Linear, quote-aware tokenizer. Shell expansion, redirection, or an unclosed quote
|
|
36
|
+
* returns undefined so callers fail closed and treat the command as dangerous.
|
|
37
37
|
*/
|
|
38
38
|
function splitSegments(command: string): string[][] | undefined {
|
|
39
39
|
const segments: string[][] = [];
|
package/src/uv-guard.ts
CHANGED
|
@@ -32,7 +32,7 @@ const PY_COMPILE_MESSAGE = [
|
|
|
32
32
|
"",
|
|
33
33
|
].join("\n");
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// Match only in command position (start, newline, after ; && || |) to avoid grep/echo arguments.
|
|
36
36
|
const SEGMENT_PREFIX = String.raw`(?:^|\n|[;|&]{1,2})\s*(?:\S+\/)?`;
|
|
37
37
|
|
|
38
38
|
const PIP_PATTERN = new RegExp(`${SEGMENT_PREFIX}pip\\s*(?:$|\\s)`, "m");
|
|
@@ -44,7 +44,7 @@ const PYTHON_VENV_PATTERN = new RegExp(`${PYTHON_PREFIX}(?:\\s-m\\s*venv\\b|\\s-
|
|
|
44
44
|
const PYTHON_PY_COMPILE_PATTERN = new RegExp(`${PYTHON_PREFIX}(?:\\s-m\\s*py_compile\\b|\\s-mpy_compile\\b)`, "m");
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Blocks disabled Python package-manager commands and suggests the uv equivalent.
|
|
48
48
|
*/
|
|
49
49
|
export function uvGuard(command: string): string | undefined {
|
|
50
50
|
if (PIP_PATTERN.test(command)) return PIP_MESSAGE;
|