claude-warden 1.8.2 → 1.8.3
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/.claude-plugin/plugin.json +1 -1
- package/dist/index.cjs +62 -7
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-warden",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "Smart command safety filter for Claude Code — parses shell pipelines and evaluates per-command safety rules to auto-approve safe commands and block dangerous ones",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "banyudu"
|
package/dist/index.cjs
CHANGED
|
@@ -18551,6 +18551,9 @@ function evaluateCommand(cmd, config, depth = 0) {
|
|
|
18551
18551
|
if (command === "xargs") {
|
|
18552
18552
|
return evaluateXargsCommand(cmd, config, depth);
|
|
18553
18553
|
}
|
|
18554
|
+
if (command === "find") {
|
|
18555
|
+
return evaluateFindCommand(cmd, config, depth);
|
|
18556
|
+
}
|
|
18554
18557
|
const mergedRule = collectMergedRule(cmd, config);
|
|
18555
18558
|
if (mergedRule) {
|
|
18556
18559
|
return evaluateRule(cmd, mergedRule);
|
|
@@ -18738,6 +18741,64 @@ function evaluateXargsCommand(cmd, config, depth = 0) {
|
|
|
18738
18741
|
matchedRule: "xargs:subcommand"
|
|
18739
18742
|
};
|
|
18740
18743
|
}
|
|
18744
|
+
function parseFindExecCommands(args2) {
|
|
18745
|
+
const commands = [];
|
|
18746
|
+
let i = 0;
|
|
18747
|
+
while (i < args2.length) {
|
|
18748
|
+
if (args2[i] === "-exec" || args2[i] === "-execdir") {
|
|
18749
|
+
i++;
|
|
18750
|
+
const cmdArgs = [];
|
|
18751
|
+
while (i < args2.length && args2[i] !== ";" && args2[i] !== "+") {
|
|
18752
|
+
if (args2[i] !== "{}") {
|
|
18753
|
+
cmdArgs.push(args2[i]);
|
|
18754
|
+
}
|
|
18755
|
+
i++;
|
|
18756
|
+
}
|
|
18757
|
+
i++;
|
|
18758
|
+
if (cmdArgs.length > 0) {
|
|
18759
|
+
commands.push({
|
|
18760
|
+
command: cmdArgs[0],
|
|
18761
|
+
originalCommand: cmdArgs[0],
|
|
18762
|
+
args: cmdArgs.slice(1),
|
|
18763
|
+
envPrefixes: [],
|
|
18764
|
+
raw: cmdArgs.join(" ")
|
|
18765
|
+
});
|
|
18766
|
+
}
|
|
18767
|
+
} else {
|
|
18768
|
+
i++;
|
|
18769
|
+
}
|
|
18770
|
+
}
|
|
18771
|
+
return commands;
|
|
18772
|
+
}
|
|
18773
|
+
function evaluateFindCommand(cmd, config, depth = 0) {
|
|
18774
|
+
const { command, args: args2 } = cmd;
|
|
18775
|
+
if (args2.some((a) => a === "-delete")) {
|
|
18776
|
+
return { command, args: args2, decision: "ask", reason: "find -delete can remove files", matchedRule: "find:delete" };
|
|
18777
|
+
}
|
|
18778
|
+
if (args2.some((a) => a === "-ok" || a === "-okdir")) {
|
|
18779
|
+
return { command, args: args2, decision: "ask", reason: "find -ok/-okdir can execute commands interactively", matchedRule: "find:ok" };
|
|
18780
|
+
}
|
|
18781
|
+
const execCommands = parseFindExecCommands(args2);
|
|
18782
|
+
if (execCommands.length === 0) {
|
|
18783
|
+
return { command, args: args2, decision: "allow", reason: "find without dangerous flags", matchedRule: "find:safe" };
|
|
18784
|
+
}
|
|
18785
|
+
for (const execCmd of execCommands) {
|
|
18786
|
+
const parsed = {
|
|
18787
|
+
commands: [execCmd],
|
|
18788
|
+
hasSubshell: false,
|
|
18789
|
+
subshellCommands: [],
|
|
18790
|
+
parseError: false
|
|
18791
|
+
};
|
|
18792
|
+
const result = evaluate(parsed, config, depth + 1);
|
|
18793
|
+
if (result.decision === "deny") {
|
|
18794
|
+
return { command, args: args2, decision: "deny", reason: `find -exec: ${result.reason}`, matchedRule: "find:exec" };
|
|
18795
|
+
}
|
|
18796
|
+
if (result.decision === "ask") {
|
|
18797
|
+
return { command, args: args2, decision: "ask", reason: `find -exec: ${result.reason}`, matchedRule: "find:exec" };
|
|
18798
|
+
}
|
|
18799
|
+
}
|
|
18800
|
+
return { command, args: args2, decision: "allow", reason: "find -exec commands are safe", matchedRule: "find:exec" };
|
|
18801
|
+
}
|
|
18741
18802
|
var SSH_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set([
|
|
18742
18803
|
"-b",
|
|
18743
18804
|
"-c",
|
|
@@ -19687,13 +19748,7 @@ var DEFAULT_CONFIG = {
|
|
|
19687
19748
|
]
|
|
19688
19749
|
},
|
|
19689
19750
|
// --- Potentially dangerous text/file tools ---
|
|
19690
|
-
|
|
19691
|
-
command: "find",
|
|
19692
|
-
default: "allow",
|
|
19693
|
-
argPatterns: [
|
|
19694
|
-
{ match: { anyArgMatches: ["^-exec$", "^-execdir$", "^-delete$", "^-ok$", "^-okdir$"] }, decision: "ask", reason: "find can execute or delete files" }
|
|
19695
|
-
]
|
|
19696
|
-
},
|
|
19751
|
+
// `find` is handled specially in the evaluator (recursive -exec evaluation)
|
|
19697
19752
|
{
|
|
19698
19753
|
command: "sed",
|
|
19699
19754
|
default: "allow",
|