clay-server 2.21.0-beta.3 → 2.21.0-beta.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/lib/sdk-bridge.js +12 -3
- package/package.json +1 -1
package/lib/sdk-bridge.js
CHANGED
|
@@ -1234,9 +1234,9 @@ function createSDKBridge(opts) {
|
|
|
1234
1234
|
// Auto-approve safe Bash commands (read-only, non-destructive)
|
|
1235
1235
|
if (toolName === "Bash" && input && input.command) {
|
|
1236
1236
|
var cmd = input.command.trim();
|
|
1237
|
-
var firstWord = cmd.split(/[\s;|&]/)[0];
|
|
1238
1237
|
var safeBashCommands = {
|
|
1239
|
-
|
|
1238
|
+
// Navigation (harmless on its own, checked in compound commands below)
|
|
1239
|
+
cd: true, pushd: true, popd: true,
|
|
1240
1240
|
// File/dir inspection
|
|
1241
1241
|
ls: true, cat: true, head: true, tail: true, wc: true, file: true,
|
|
1242
1242
|
stat: true, find: true, tree: true, du: true, df: true,
|
|
@@ -1273,7 +1273,16 @@ function createSDKBridge(opts) {
|
|
|
1273
1273
|
nslookup: true, host: true, ping: true, traceroute: true,
|
|
1274
1274
|
curl: true, wget: true, http: true,
|
|
1275
1275
|
};
|
|
1276
|
-
|
|
1276
|
+
// Split compound commands (&&, ||, ;, |) and check ALL segments
|
|
1277
|
+
var segments = cmd.split(/\s*(?:&&|\|\||[;|])\s*/);
|
|
1278
|
+
var allSafe = true;
|
|
1279
|
+
for (var si = 0; si < segments.length; si++) {
|
|
1280
|
+
var seg = segments[si].trim();
|
|
1281
|
+
if (!seg) continue;
|
|
1282
|
+
var firstWord = seg.split(/\s/)[0];
|
|
1283
|
+
if (!safeBashCommands[firstWord]) { allSafe = false; break; }
|
|
1284
|
+
}
|
|
1285
|
+
if (allSafe) {
|
|
1277
1286
|
return Promise.resolve({ behavior: "allow", updatedInput: input });
|
|
1278
1287
|
}
|
|
1279
1288
|
}
|