claude-warden 1.5.2 → 1.6.0
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 +71 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-warden",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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
|
@@ -18143,6 +18143,53 @@ function preprocessCatHeredocs(input) {
|
|
|
18143
18143
|
const regex = /\$\(cat\s+<<-?\s*['"]?(\w+)['"]?\n([\s\S]*?)\n\1\s*\)/g;
|
|
18144
18144
|
return input.replace(regex, "__HEREDOC_TEXT__");
|
|
18145
18145
|
}
|
|
18146
|
+
function preprocessPathParentheses(input) {
|
|
18147
|
+
const result = [];
|
|
18148
|
+
let i = 0;
|
|
18149
|
+
while (i < input.length) {
|
|
18150
|
+
const ch = input[i];
|
|
18151
|
+
if (ch === '"' || ch === "'") {
|
|
18152
|
+
const quote = ch;
|
|
18153
|
+
let j = i + 1;
|
|
18154
|
+
while (j < input.length && input[j] !== quote) {
|
|
18155
|
+
if (input[j] === "\\" && quote === '"') j++;
|
|
18156
|
+
j++;
|
|
18157
|
+
}
|
|
18158
|
+
result.push(input.slice(i, j + 1));
|
|
18159
|
+
i = j + 1;
|
|
18160
|
+
continue;
|
|
18161
|
+
}
|
|
18162
|
+
if (ch === "$" && i + 1 < input.length && input[i + 1] === "(") {
|
|
18163
|
+
let depth = 1;
|
|
18164
|
+
let j = i + 2;
|
|
18165
|
+
while (j < input.length && depth > 0) {
|
|
18166
|
+
if (input[j] === "(") depth++;
|
|
18167
|
+
else if (input[j] === ")") depth--;
|
|
18168
|
+
if (depth > 0) j++;
|
|
18169
|
+
}
|
|
18170
|
+
result.push(input.slice(i, j + 1));
|
|
18171
|
+
i = j + 1;
|
|
18172
|
+
continue;
|
|
18173
|
+
}
|
|
18174
|
+
if (ch !== " " && ch !== " " && ch !== "\n") {
|
|
18175
|
+
let j = i;
|
|
18176
|
+
while (j < input.length && !" \n".includes(input[j]) && input[j] !== '"' && input[j] !== "'" && !(input[j] === "$" && j + 1 < input.length && input[j + 1] === "(")) {
|
|
18177
|
+
j++;
|
|
18178
|
+
}
|
|
18179
|
+
const token = input.slice(i, j);
|
|
18180
|
+
if (token.includes("/") && /[()]/.test(token) && !/^[<>|;&]/.test(token)) {
|
|
18181
|
+
result.push('"' + token + '"');
|
|
18182
|
+
} else {
|
|
18183
|
+
result.push(token);
|
|
18184
|
+
}
|
|
18185
|
+
i = j;
|
|
18186
|
+
continue;
|
|
18187
|
+
}
|
|
18188
|
+
result.push(ch);
|
|
18189
|
+
i++;
|
|
18190
|
+
}
|
|
18191
|
+
return result.join("");
|
|
18192
|
+
}
|
|
18146
18193
|
function convertCommand(node) {
|
|
18147
18194
|
if (!node.name) return null;
|
|
18148
18195
|
const originalCommand = node.name.text;
|
|
@@ -18290,6 +18337,7 @@ function parseCommand(input) {
|
|
|
18290
18337
|
return { commands: [], hasSubshell: false, subshellCommands: [], parseError: false };
|
|
18291
18338
|
}
|
|
18292
18339
|
input = preprocessCatHeredocs(input);
|
|
18340
|
+
input = preprocessPathParentheses(input);
|
|
18293
18341
|
try {
|
|
18294
18342
|
const ast = (0, import_bash_parser.default)(input);
|
|
18295
18343
|
const result = { commands: [], hasSubshell: false, subshellCommands: [] };
|
|
@@ -19222,6 +19270,7 @@ var DEFAULT_CONFIG = {
|
|
|
19222
19270
|
"sudo",
|
|
19223
19271
|
"su",
|
|
19224
19272
|
"doas",
|
|
19273
|
+
"eval",
|
|
19225
19274
|
"mkfs",
|
|
19226
19275
|
"fdisk",
|
|
19227
19276
|
"dd",
|
|
@@ -19253,6 +19302,28 @@ var DEFAULT_CONFIG = {
|
|
|
19253
19302
|
{ match: { anyArgMatches: ["^--(version|help)$", "^-[vh]$"] }, decision: "allow", description: "Version/help flags" }
|
|
19254
19303
|
]
|
|
19255
19304
|
},
|
|
19305
|
+
// --- Shell sourcing ---
|
|
19306
|
+
...["source", "."].map((cmd) => ({
|
|
19307
|
+
command: cmd,
|
|
19308
|
+
default: "ask",
|
|
19309
|
+
argPatterns: [
|
|
19310
|
+
{
|
|
19311
|
+
match: { anyArgMatches: [
|
|
19312
|
+
"(\\.bashrc|\\.zshrc|\\.profile|\\.bash_profile|\\.zprofile|\\.shrc)$",
|
|
19313
|
+
"nvm\\.sh$",
|
|
19314
|
+
"\\.envrc$",
|
|
19315
|
+
"\\.env$"
|
|
19316
|
+
] },
|
|
19317
|
+
decision: "allow",
|
|
19318
|
+
description: "Common shell config and env files"
|
|
19319
|
+
},
|
|
19320
|
+
{
|
|
19321
|
+
match: { noArgs: true },
|
|
19322
|
+
decision: "deny",
|
|
19323
|
+
reason: "source/. requires a file argument"
|
|
19324
|
+
}
|
|
19325
|
+
]
|
|
19326
|
+
})),
|
|
19256
19327
|
// --- Shell interpreters ---
|
|
19257
19328
|
...["bash", "sh", "zsh"].map((cmd) => ({
|
|
19258
19329
|
command: cmd,
|