@dcrays/mobook-security-plugin 2.0.6 → 2.0.7

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.
Files changed (2) hide show
  1. package/index.js +26 -4
  2. package/package.json +4 -2
package/index.js CHANGED
@@ -615,11 +615,11 @@ export default function register(api) {
615
615
  }
616
616
  }
617
617
 
618
- // 禁止通过 config 工具关闭插件
618
+ // 禁止通过 config 工具关闭插件(覆盖所有参数字段)
619
619
  if (toolName === "gateway") {
620
- const raw = params.raw || params.path || JSON.stringify(params);
621
- if (/mobook-security-plugin/.test(raw) && /(disable|false|remove|delete)/.test(raw)) {
622
- alert(`BLOCKED: 尝试通过配置关闭安全插件`);
620
+ const allParams = JSON.stringify(params);
621
+ if (/mobook-security-plugin/.test(allParams) && /(disable|false|remove|delete|uninstall)/.test(allParams)) {
622
+ alert(`BLOCKED: 尝试通过配置关闭安全插件 | params: ${allParams.slice(0, 300)}`);
623
623
  return {
624
624
  block: true,
625
625
  blockReason: "🛡️ 安全插件拦截:禁止通过配置关闭安全插件"
@@ -627,6 +627,28 @@ export default function register(api) {
627
627
  }
628
628
  }
629
629
 
630
+ // 禁止直接编辑 openclaw.json 来关闭插件
631
+ if (["edit", "write", "exec"].includes(toolName)) {
632
+ const pathValues = [params.path || "", params.command || "", params.file || ""].join(" ");
633
+ const isConfigFile = /openclaw\.json/.test(pathValues);
634
+ if (isConfigFile) {
635
+ log(`CONFIG_FILE_CHECK: tool=${toolName} path=${params.path || ""} edits=${JSON.stringify(params.edits || "").slice(0, 200)} content=${(params.content || "").slice(0, 100)}`, "DEBUG");
636
+ // 检查内容是否涉及禁用安全插件
637
+ const contentValues = [
638
+ params.command || "",
639
+ JSON.stringify(params.edits || ""),
640
+ params.content || ""
641
+ ].join(" ");
642
+ if (/mobook-security-plugin/.test(contentValues) && /(false|disable|remove|delete|\[\])/.test(contentValues)) {
643
+ alert(`BLOCKED: 尝试通过直接编辑 openclaw.json 关闭安全插件 | tool=${toolName}`);
644
+ return {
645
+ block: true,
646
+ blockReason: "🛡️ 安全插件拦截:禁止通过修改配置文件关闭安全插件"
647
+ };
648
+ }
649
+ }
650
+ }
651
+
630
652
  return {};
631
653
  });
632
654
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcrays/mobook-security-plugin",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "type": "module",
5
5
  "description": "MoBook 企业级安全插件 - 危险命令分级拦截、敏感信息全渠道脱敏(身份证GB11643/银行卡Luhn校验)、LLM响应拦截、操作审计",
6
6
  "main": "index.js",
@@ -16,6 +16,8 @@
16
16
  "type": "plugin",
17
17
  "id": "mobook-security-plugin",
18
18
  "name": "MoBook 安全防护插件",
19
- "extensions": ["./index.js"]
19
+ "extensions": [
20
+ "./index.js"
21
+ ]
20
22
  }
21
23
  }