pi-landstrip 0.20.23 → 0.20.25
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 -13
- 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
|
}
|
|
@@ -6717,8 +6723,6 @@ var WINDOWS_LAUNCHER_ENVIRONMENT = [
|
|
|
6717
6723
|
"PATHEXT"
|
|
6718
6724
|
];
|
|
6719
6725
|
function createLandstripLauncherEnvironment(providerEnv, hostEnv = process.env, platform = process.platform) {
|
|
6720
|
-
if (platform === "linux")
|
|
6721
|
-
return { ...providerEnv, APPIMAGE_EXTRACT_AND_RUN: "1" };
|
|
6722
6726
|
if (platform !== "win32")
|
|
6723
6727
|
return providerEnv;
|
|
6724
6728
|
const result = { ...providerEnv };
|
|
@@ -7092,10 +7096,13 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7092
7096
|
}
|
|
7093
7097
|
async function resolveTrapQuery(trap, ctx, cwd, allowances, promptOnBlock, signal, readScope) {
|
|
7094
7098
|
if (trap.kind !== "filesystem") {
|
|
7095
|
-
const key = `${trap.operation}\x00${trap.target}`;
|
|
7096
7099
|
const isUnixSocket = isAbsolute4(trap.target);
|
|
7097
7100
|
const socketPath = isUnixSocket ? normalizeBlockedPath(trap.target, cwd) : trap.target;
|
|
7101
|
+
const key = `${trap.operation}\x00${socketPath}`;
|
|
7098
7102
|
const current = () => {
|
|
7103
|
+
if (allowances.rejectedTargets?.has(key)) {
|
|
7104
|
+
return { action: "deny", reason: "rejected" };
|
|
7105
|
+
}
|
|
7099
7106
|
if (sessionGrants.hasTarget(key, allowances)) {
|
|
7100
7107
|
return { action: "allow" };
|
|
7101
7108
|
}
|
|
@@ -7112,10 +7119,18 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7112
7119
|
}
|
|
7113
7120
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
7114
7121
|
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)
|
|
7122
|
+
if (choice === "abort" || promptSignal.aborted) {
|
|
7123
|
+
if (!promptSignal.aborted)
|
|
7124
|
+
(allowances.rejectedTargets ??= new Set).add(key);
|
|
7116
7125
|
return { action: "deny", reason: "rejected" };
|
|
7126
|
+
}
|
|
7117
7127
|
if (isUnixSocket) {
|
|
7118
|
-
|
|
7128
|
+
try {
|
|
7129
|
+
await applyUnixSocketChoice(ctx, choice, socketPath, key, cwd, allowances);
|
|
7130
|
+
} catch (error) {
|
|
7131
|
+
(allowances.rejectedTargets ??= new Set).add(key);
|
|
7132
|
+
throw error;
|
|
7133
|
+
}
|
|
7119
7134
|
} else {
|
|
7120
7135
|
sessionGrants.grantTarget(choice, key, allowances);
|
|
7121
7136
|
}
|
|
@@ -7188,7 +7203,13 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7188
7203
|
prompts = prompts.then(async () => {
|
|
7189
7204
|
const result = await resolveTrapQuery(trap, ctx, cwd, allowances, true, signal);
|
|
7190
7205
|
respond(trap.query_id, result.action);
|
|
7191
|
-
}).catch(() =>
|
|
7206
|
+
}).catch((error) => {
|
|
7207
|
+
respond(trap.query_id, "deny");
|
|
7208
|
+
if (!signal?.aborted && formatError(error) !== "Permission request cancelled") {
|
|
7209
|
+
const target = isFilesystemTrap(trap) ? trap.path : trap.target;
|
|
7210
|
+
reportTrapError(`Sandbox permission request failed (${trap.operation} "${target}"): ${formatError(error)}`);
|
|
7211
|
+
}
|
|
7212
|
+
});
|
|
7192
7213
|
};
|
|
7193
7214
|
socket.on("error", (error) => {
|
|
7194
7215
|
reportTrapError(`Worker sandbox control failed: ${error.message}`);
|
|
@@ -7541,6 +7562,7 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7541
7562
|
};
|
|
7542
7563
|
}
|
|
7543
7564
|
function createLandstripBashOps(ctx, callbacks = {}, allowances = { domains: [], readPaths: [], writePaths: [], targets: [] }) {
|
|
7565
|
+
allowances.rejectedTargets ??= new Set;
|
|
7544
7566
|
return {
|
|
7545
7567
|
async exec(command, cwd, { onData, signal, timeout, env }) {
|
|
7546
7568
|
if (!existsSync6(cwd))
|
|
@@ -7739,7 +7761,16 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7739
7761
|
appendErrorLine(line);
|
|
7740
7762
|
}
|
|
7741
7763
|
respondQuery(trap.query_id, result.action);
|
|
7742
|
-
}).catch(() =>
|
|
7764
|
+
}).catch((error) => {
|
|
7765
|
+
respondQuery(trap.query_id, "deny");
|
|
7766
|
+
if (!signal?.aborted && formatError(error) !== "Permission request cancelled") {
|
|
7767
|
+
const target = isFilesystemTrap(trap) ? trap.path : trap.target;
|
|
7768
|
+
const message = `Sandbox permission request failed (${trap.operation} "${target}"): ${formatError(error)}`;
|
|
7769
|
+
appendErrorLine(JSON.stringify({ kind: "internal", code: "INTERNAL_ERROR", message }));
|
|
7770
|
+
onData(Buffer.from(`pi-landstrip: ${message}
|
|
7771
|
+
`, "utf8"));
|
|
7772
|
+
}
|
|
7773
|
+
});
|
|
7743
7774
|
} else {
|
|
7744
7775
|
appendErrorLine(line);
|
|
7745
7776
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-landstrip",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.25",
|
|
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.25",
|
|
43
43
|
"jsonc-parser": "^3.3.1",
|
|
44
44
|
"minimatch": "^10.2.5",
|
|
45
45
|
"semver": "^7.8.6",
|