claude-warden 1.1.7 → 1.1.9
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 +60 -18
- package/package.json +13 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-warden",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.9",
|
|
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
|
@@ -18258,37 +18258,78 @@ function walkNode(node, result) {
|
|
|
18258
18258
|
break;
|
|
18259
18259
|
}
|
|
18260
18260
|
}
|
|
18261
|
+
function hasHeredocRedirect(node) {
|
|
18262
|
+
if (!node.suffix) return false;
|
|
18263
|
+
return node.suffix.some((s) => s.type === "dless" || s.type === "dlessdash");
|
|
18264
|
+
}
|
|
18265
|
+
function astHasHeredoc(ast) {
|
|
18266
|
+
function check(node) {
|
|
18267
|
+
if (node.type === "Command") {
|
|
18268
|
+
if (hasHeredocRedirect(node)) return true;
|
|
18269
|
+
}
|
|
18270
|
+
for (const [key, value] of Object.entries(node)) {
|
|
18271
|
+
if (key === "commandAST" || key === "expansion") continue;
|
|
18272
|
+
if (Array.isArray(value)) {
|
|
18273
|
+
for (const child of value) {
|
|
18274
|
+
if (child && typeof child === "object" && "type" in child && check(child)) return true;
|
|
18275
|
+
}
|
|
18276
|
+
} else if (value && typeof value === "object" && "type" in value) {
|
|
18277
|
+
if (check(value)) return true;
|
|
18278
|
+
}
|
|
18279
|
+
}
|
|
18280
|
+
return false;
|
|
18281
|
+
}
|
|
18282
|
+
for (const cmd of ast.commands) {
|
|
18283
|
+
if (check(cmd)) return true;
|
|
18284
|
+
}
|
|
18285
|
+
return false;
|
|
18286
|
+
}
|
|
18261
18287
|
function parseCommand(input) {
|
|
18262
18288
|
if (!input || !input.trim()) {
|
|
18263
18289
|
return { commands: [], hasSubshell: false, subshellCommands: [], parseError: false };
|
|
18264
18290
|
}
|
|
18265
18291
|
input = preprocessCatHeredocs(input);
|
|
18266
|
-
const hasHeredoc = HEREDOC_REGEX.test(input);
|
|
18267
|
-
if (hasHeredoc) {
|
|
18268
|
-
const firstLine = input.split("\n")[0];
|
|
18269
|
-
const cmdPart = firstLine.replace(/<<-?\s*['"]?\w+['"]?.*$/, "").trim();
|
|
18270
|
-
if (!cmdPart) {
|
|
18271
|
-
return { commands: [], hasSubshell: false, subshellCommands: [], parseError: true };
|
|
18272
|
-
}
|
|
18273
|
-
try {
|
|
18274
|
-
const ast = (0, import_bash_parser.default)(cmdPart);
|
|
18275
|
-
const result = { commands: [], hasSubshell: false, subshellCommands: [] };
|
|
18276
|
-
for (const cmd of ast.commands) {
|
|
18277
|
-
walkNode(cmd, result);
|
|
18278
|
-
}
|
|
18279
|
-
return { commands: result.commands, hasSubshell: true, subshellCommands: result.subshellCommands, parseError: false };
|
|
18280
|
-
} catch {
|
|
18281
|
-
return { commands: [], hasSubshell: true, subshellCommands: [], parseError: true };
|
|
18282
|
-
}
|
|
18283
|
-
}
|
|
18284
18292
|
try {
|
|
18285
18293
|
const ast = (0, import_bash_parser.default)(input);
|
|
18286
18294
|
const result = { commands: [], hasSubshell: false, subshellCommands: [] };
|
|
18295
|
+
if (astHasHeredoc(ast)) {
|
|
18296
|
+
const firstLine = input.split("\n")[0];
|
|
18297
|
+
const cmdPart = firstLine.replace(/<<-?\s*['"]?\w+['"]?.*$/, "").trim();
|
|
18298
|
+
if (!cmdPart) {
|
|
18299
|
+
return { commands: [], hasSubshell: false, subshellCommands: [], parseError: true };
|
|
18300
|
+
}
|
|
18301
|
+
try {
|
|
18302
|
+
const cmdAst = (0, import_bash_parser.default)(cmdPart);
|
|
18303
|
+
for (const cmd of cmdAst.commands) {
|
|
18304
|
+
walkNode(cmd, result);
|
|
18305
|
+
}
|
|
18306
|
+
return { commands: result.commands, hasSubshell: true, subshellCommands: result.subshellCommands, parseError: false };
|
|
18307
|
+
} catch {
|
|
18308
|
+
return { commands: [], hasSubshell: true, subshellCommands: [], parseError: true };
|
|
18309
|
+
}
|
|
18310
|
+
}
|
|
18287
18311
|
for (const cmd of ast.commands) {
|
|
18288
18312
|
walkNode(cmd, result);
|
|
18289
18313
|
}
|
|
18290
18314
|
return { commands: result.commands, hasSubshell: result.hasSubshell, subshellCommands: result.subshellCommands, parseError: false };
|
|
18291
18315
|
} catch {
|
|
18316
|
+
if (HEREDOC_REGEX.test(input)) {
|
|
18317
|
+
const firstLine = input.split("\n")[0];
|
|
18318
|
+
const cmdPart = firstLine.replace(/<<-?\s*['"]?\w+['"]?.*$/, "").trim();
|
|
18319
|
+
if (!cmdPart) {
|
|
18320
|
+
return { commands: [], hasSubshell: true, subshellCommands: [], parseError: true };
|
|
18321
|
+
}
|
|
18322
|
+
try {
|
|
18323
|
+
const ast = (0, import_bash_parser.default)(cmdPart);
|
|
18324
|
+
const result = { commands: [], hasSubshell: false, subshellCommands: [] };
|
|
18325
|
+
for (const cmd of ast.commands) {
|
|
18326
|
+
walkNode(cmd, result);
|
|
18327
|
+
}
|
|
18328
|
+
return { commands: result.commands, hasSubshell: true, subshellCommands: result.subshellCommands, parseError: false };
|
|
18329
|
+
} catch {
|
|
18330
|
+
return { commands: [], hasSubshell: true, subshellCommands: [], parseError: true };
|
|
18331
|
+
}
|
|
18332
|
+
}
|
|
18292
18333
|
return { commands: [], hasSubshell: false, subshellCommands: [], parseError: true };
|
|
18293
18334
|
}
|
|
18294
18335
|
}
|
|
@@ -19043,6 +19084,7 @@ var DEFAULT_CONFIG = {
|
|
|
19043
19084
|
"dirs",
|
|
19044
19085
|
"hash",
|
|
19045
19086
|
"alias",
|
|
19087
|
+
"set",
|
|
19046
19088
|
"sleep",
|
|
19047
19089
|
"wait",
|
|
19048
19090
|
"time",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-warden",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Smart command safety filter for Claude Code — auto-approves safe commands, blocks dangerous ones",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -28,15 +28,6 @@
|
|
|
28
28
|
"README.md",
|
|
29
29
|
"LICENSE"
|
|
30
30
|
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsup",
|
|
33
|
-
"dev": "tsup --watch",
|
|
34
|
-
"test": "vitest run",
|
|
35
|
-
"test:watch": "vitest",
|
|
36
|
-
"typecheck": "tsc --noEmit",
|
|
37
|
-
"eval": "node dist/index.cjs",
|
|
38
|
-
"prepublishOnly": "pnpm run build && pnpm run test"
|
|
39
|
-
},
|
|
40
31
|
"devDependencies": {
|
|
41
32
|
"@types/node": "^20.0.0",
|
|
42
33
|
"bash-parser": "^0.5.0",
|
|
@@ -44,5 +35,16 @@
|
|
|
44
35
|
"typescript": "^5.4.0",
|
|
45
36
|
"vitest": "^1.6.0",
|
|
46
37
|
"yaml": "^2.4.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"eval": "node dist/index.cjs",
|
|
46
|
+
"sync-plugin-version": "node -e \"const p=require('./package.json'),fs=require('fs'),f='.claude-plugin/plugin.json',j=JSON.parse(fs.readFileSync(f));j.version=p.version;fs.writeFileSync(f,JSON.stringify(j,null,2)+'\\n')\"",
|
|
47
|
+
"docs:dev": "cd docs-src && pnpm dev",
|
|
48
|
+
"docs:build": "cd docs-src && pnpm install && pnpm build"
|
|
47
49
|
}
|
|
48
|
-
}
|
|
50
|
+
}
|