pi-landstrip 0.20.22 → 0.20.24
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/dist/index.ts +44 -11
- package/package.json +2 -2
package/dist/index.ts
CHANGED
|
@@ -6354,12 +6354,18 @@ class SandboxConfigStore {
|
|
|
6354
6354
|
const configPath = choice === "global" ? this.globalPath : choice === "project" && includeProject ? this.projectPath : undefined;
|
|
6355
6355
|
if (!configPath)
|
|
6356
6356
|
return;
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6357
|
+
try {
|
|
6358
|
+
for (const value of values) {
|
|
6359
|
+
await withFileMutationQueue3(configPath, async () => {
|
|
6360
|
+
const config = SandboxConfigStore.readOrEmpty(configPath);
|
|
6361
|
+
if (!SandboxConfigStore.appendGrant(config, field, value))
|
|
6362
|
+
return;
|
|
6363
|
+
SandboxConfigStore.write(configPath, config);
|
|
6364
|
+
});
|
|
6365
|
+
}
|
|
6366
|
+
} catch (error) {
|
|
6367
|
+
throw new Error(`Failed to save sandbox permission to "${configPath}": ${formatError(error)}`, {
|
|
6368
|
+
cause: error
|
|
6363
6369
|
});
|
|
6364
6370
|
}
|
|
6365
6371
|
}
|
|
@@ -7092,10 +7098,13 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7092
7098
|
}
|
|
7093
7099
|
async function resolveTrapQuery(trap, ctx, cwd, allowances, promptOnBlock, signal, readScope) {
|
|
7094
7100
|
if (trap.kind !== "filesystem") {
|
|
7095
|
-
const key = `${trap.operation}\x00${trap.target}`;
|
|
7096
7101
|
const isUnixSocket = isAbsolute4(trap.target);
|
|
7097
7102
|
const socketPath = isUnixSocket ? normalizeBlockedPath(trap.target, cwd) : trap.target;
|
|
7103
|
+
const key = `${trap.operation}\x00${socketPath}`;
|
|
7098
7104
|
const current = () => {
|
|
7105
|
+
if (allowances.rejectedTargets?.has(key)) {
|
|
7106
|
+
return { action: "deny", reason: "rejected" };
|
|
7107
|
+
}
|
|
7099
7108
|
if (sessionGrants.hasTarget(key, allowances)) {
|
|
7100
7109
|
return { action: "allow" };
|
|
7101
7110
|
}
|
|
@@ -7112,10 +7121,18 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7112
7121
|
}
|
|
7113
7122
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
7114
7123
|
const choice = await showPermissionPrompt(ctx, isUnixSocket ? `Unix socket blocked: ${trap.operation} "${socketPath}"` : `Network blocked: ${trap.operation} "${trap.target}"`, isUnixSocket ? permissionOptionsFor(ctx) : NETWORK_PERMISSION_OPTIONS, promptSignal, allowances.permissionPromptLabel);
|
|
7115
|
-
if (choice === "abort" || promptSignal.aborted)
|
|
7124
|
+
if (choice === "abort" || promptSignal.aborted) {
|
|
7125
|
+
if (!promptSignal.aborted)
|
|
7126
|
+
(allowances.rejectedTargets ??= new Set).add(key);
|
|
7116
7127
|
return { action: "deny", reason: "rejected" };
|
|
7128
|
+
}
|
|
7117
7129
|
if (isUnixSocket) {
|
|
7118
|
-
|
|
7130
|
+
try {
|
|
7131
|
+
await applyUnixSocketChoice(ctx, choice, socketPath, key, cwd, allowances);
|
|
7132
|
+
} catch (error) {
|
|
7133
|
+
(allowances.rejectedTargets ??= new Set).add(key);
|
|
7134
|
+
throw error;
|
|
7135
|
+
}
|
|
7119
7136
|
} else {
|
|
7120
7137
|
sessionGrants.grantTarget(choice, key, allowances);
|
|
7121
7138
|
}
|
|
@@ -7188,7 +7205,13 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7188
7205
|
prompts = prompts.then(async () => {
|
|
7189
7206
|
const result = await resolveTrapQuery(trap, ctx, cwd, allowances, true, signal);
|
|
7190
7207
|
respond(trap.query_id, result.action);
|
|
7191
|
-
}).catch(() =>
|
|
7208
|
+
}).catch((error) => {
|
|
7209
|
+
respond(trap.query_id, "deny");
|
|
7210
|
+
if (!signal?.aborted && formatError(error) !== "Permission request cancelled") {
|
|
7211
|
+
const target = isFilesystemTrap(trap) ? trap.path : trap.target;
|
|
7212
|
+
reportTrapError(`Sandbox permission request failed (${trap.operation} "${target}"): ${formatError(error)}`);
|
|
7213
|
+
}
|
|
7214
|
+
});
|
|
7192
7215
|
};
|
|
7193
7216
|
socket.on("error", (error) => {
|
|
7194
7217
|
reportTrapError(`Worker sandbox control failed: ${error.message}`);
|
|
@@ -7541,6 +7564,7 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7541
7564
|
};
|
|
7542
7565
|
}
|
|
7543
7566
|
function createLandstripBashOps(ctx, callbacks = {}, allowances = { domains: [], readPaths: [], writePaths: [], targets: [] }) {
|
|
7567
|
+
allowances.rejectedTargets ??= new Set;
|
|
7544
7568
|
return {
|
|
7545
7569
|
async exec(command, cwd, { onData, signal, timeout, env }) {
|
|
7546
7570
|
if (!existsSync6(cwd))
|
|
@@ -7739,7 +7763,16 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7739
7763
|
appendErrorLine(line);
|
|
7740
7764
|
}
|
|
7741
7765
|
respondQuery(trap.query_id, result.action);
|
|
7742
|
-
}).catch(() =>
|
|
7766
|
+
}).catch((error) => {
|
|
7767
|
+
respondQuery(trap.query_id, "deny");
|
|
7768
|
+
if (!signal?.aborted && formatError(error) !== "Permission request cancelled") {
|
|
7769
|
+
const target = isFilesystemTrap(trap) ? trap.path : trap.target;
|
|
7770
|
+
const message = `Sandbox permission request failed (${trap.operation} "${target}"): ${formatError(error)}`;
|
|
7771
|
+
appendErrorLine(JSON.stringify({ kind: "internal", code: "INTERNAL_ERROR", message }));
|
|
7772
|
+
onData(Buffer.from(`pi-landstrip: ${message}
|
|
7773
|
+
`, "utf8"));
|
|
7774
|
+
}
|
|
7775
|
+
});
|
|
7743
7776
|
} else {
|
|
7744
7777
|
appendErrorLine(line);
|
|
7745
7778
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-landstrip",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.24",
|
|
4
4
|
"description": "Sandboxed Bash and process-backed agents for Pi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"landstrip",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"ci:test": "npm run test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@landstrip/landstrip-api": "^0.20.
|
|
42
|
+
"@landstrip/landstrip-api": "^0.20.24",
|
|
43
43
|
"jsonc-parser": "^3.3.1",
|
|
44
44
|
"minimatch": "^10.2.5",
|
|
45
45
|
"semver": "^7.8.6",
|