@dcrays/mobook-security-plugin 2.0.14 → 2.0.15
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/index.js +47 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -749,6 +749,53 @@ export default function register(api) {
|
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
|
|
752
|
+
// ============================================================
|
|
753
|
+
// 禁止 OpenClaw 自动更新
|
|
754
|
+
// ============================================================
|
|
755
|
+
|
|
756
|
+
// 路径1:gateway 工具 update.run
|
|
757
|
+
if (toolName === "gateway" && params?.action === "update.run") {
|
|
758
|
+
alert(`BLOCKED: 尝试通过 gateway 更新 OpenClaw`);
|
|
759
|
+
return {
|
|
760
|
+
block: true,
|
|
761
|
+
blockReason: "🛡️ 安全插件拦截:禁止自动更新 OpenClaw,需人工确认后手动执行"
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// 路径2:gateway config 修改自动更新相关配置
|
|
766
|
+
if (toolName === "gateway" && ["config.patch", "config.apply"].includes(params?.action)) {
|
|
767
|
+
const raw = params?.raw || JSON.stringify(params);
|
|
768
|
+
if (/auto.?update|"updates?"/i.test(raw)) {
|
|
769
|
+
alert(`BLOCKED: 尝试通过配置修改 OpenClaw 自动更新设置 | action=${params.action}`);
|
|
770
|
+
return {
|
|
771
|
+
block: true,
|
|
772
|
+
blockReason: "🛡️ 安全插件拦截:禁止修改 OpenClaw 自动更新配置,需人工确认"
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// 路径3:exec 命令安装/更新 OpenClaw
|
|
778
|
+
if (toolName === "exec") {
|
|
779
|
+
const cmd = params.command || "";
|
|
780
|
+
const openclawUpdatePatterns = [
|
|
781
|
+
/npm\s+(i|install|update|up|upgrade)\s+.*\bopenclaw\b/i,
|
|
782
|
+
/yarn\s+(global\s+)?add\s+.*\bopenclaw\b/i,
|
|
783
|
+
/yarn\s+(global\s+)?upgrade\s+.*\bopenclaw\b/i,
|
|
784
|
+
/pnpm\s+(add|update|install|upgrade)\s+.*\bopenclaw\b/i,
|
|
785
|
+
/npx\s+.*\bopenclaw\b.*update/i,
|
|
786
|
+
/brew\s+(upgrade|reinstall)\s+.*\bopenclaw\b/i,
|
|
787
|
+
/\bopenclaw\s+update\b/i,
|
|
788
|
+
/\bopenclaw\s+gateway\s+update\b/i,
|
|
789
|
+
];
|
|
790
|
+
if (openclawUpdatePatterns.some(p => p.test(cmd))) {
|
|
791
|
+
alert(`BLOCKED: 尝试通过命令行更新 OpenClaw | cmd: ${cmd.slice(0, 200)}`);
|
|
792
|
+
return {
|
|
793
|
+
block: true,
|
|
794
|
+
blockReason: "🛡️ 安全插件拦截:禁止通过包管理器更新 OpenClaw,需人工确认后手动执行"
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
752
799
|
return {};
|
|
753
800
|
});
|
|
754
801
|
|
package/openclaw.plugin.json
CHANGED