@dcrays/mobook-security-plugin 2.0.4 → 2.0.5
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 +10 -11
- package/openclaw.plugin.json +2 -2
- package/package.json +10 -2
package/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import * as os from "node:os";
|
|
4
3
|
|
|
5
4
|
// ============================================================
|
|
6
|
-
// MoBook 安全防护插件 v2.0
|
|
5
|
+
// MoBook 安全防护插件 v2.0
|
|
7
6
|
// 功能:危险命令拦截 | 敏感信息脱敏(全渠道) | LLM 响应拦截 | 操作审计日志
|
|
8
7
|
// ============================================================
|
|
9
8
|
|
|
10
|
-
const LOG_DIR =
|
|
9
|
+
const LOG_DIR = "/tmp/mobook-security";
|
|
11
10
|
const LOG_FILE = path.join(LOG_DIR, "security.log");
|
|
12
11
|
const ALERT_FILE = path.join(LOG_DIR, "alerts.log");
|
|
13
12
|
|
|
@@ -77,9 +76,9 @@ const DANGEROUS_COMMANDS = [
|
|
|
77
76
|
{ pattern: /\bexport\s+HISTSIZE=0/i, reason: "禁用命令历史", severity: "HIGH" },
|
|
78
77
|
{ pattern: />\s*\/var\/log\//i, reason: "清空系统日志", severity: "CRITICAL" },
|
|
79
78
|
|
|
80
|
-
// ---
|
|
81
|
-
{ pattern:
|
|
82
|
-
{ pattern:
|
|
79
|
+
// --- 加密货币挖矿 ---
|
|
80
|
+
{ pattern: /\bxmrig\b|\bminerd\b|\bcpuminer\b/i, reason: "加密货币挖矿程序", severity: "CRITICAL" },
|
|
81
|
+
{ pattern: /stratum\+tcp:\/\//i, reason: "挖矿矿池连接", severity: "CRITICAL" },
|
|
83
82
|
];
|
|
84
83
|
|
|
85
84
|
const BLOCK_SEVERITIES = new Set(["CRITICAL", "HIGH"]);
|
|
@@ -175,7 +174,7 @@ const SENSITIVE_PATTERNS = [
|
|
|
175
174
|
name: "GitHub Token"
|
|
176
175
|
},
|
|
177
176
|
{
|
|
178
|
-
pattern: /(password|passwd|pwd|secret|token|api_key|apikey|access_key|private_key)\s*[=:]\s*["']?[^\s"',]{6,}/gi,
|
|
177
|
+
pattern: /(password|passwd|pwd|secret_key|secret|token|api_key|apikey|access_key|private_key)\s*[=:]\s*["']?[^\s"',]{6,}/gi,
|
|
179
178
|
replacement: "$1=***已脱敏***",
|
|
180
179
|
name: "密码/密钥字段"
|
|
181
180
|
},
|
|
@@ -205,8 +204,8 @@ function sanitizeContent(content) {
|
|
|
205
204
|
if (hasMatch) matches.push(rule.name);
|
|
206
205
|
} else if (rule.replacement) {
|
|
207
206
|
rule.pattern.lastIndex = 0;
|
|
208
|
-
|
|
209
|
-
const replaced = sanitized.replace(rule.pattern,
|
|
207
|
+
const repl = rule.replacement; // 闭包捕获
|
|
208
|
+
const replaced = sanitized.replace(rule.pattern, () => repl);
|
|
210
209
|
if (replaced !== sanitized) {
|
|
211
210
|
matches.push(rule.name);
|
|
212
211
|
sanitized = replaced;
|
|
@@ -508,7 +507,7 @@ function installFetchInterceptor(api) {
|
|
|
508
507
|
// ============================================================
|
|
509
508
|
export default function register(api) {
|
|
510
509
|
log("═══════════════════════════════════════════════════════");
|
|
511
|
-
log(" MoBook 安全防护插件 v2.0
|
|
510
|
+
log(" MoBook 安全防护插件 v2.0 启动");
|
|
512
511
|
log(" 功能: 危险命令拦截 | 敏感信息脱敏(全渠道) | LLM 响应拦截 | 提示词注入检测 | 操作审计");
|
|
513
512
|
log("═══════════════════════════════════════════════════════");
|
|
514
513
|
log(`插件ID: ${api.id}`);
|
|
@@ -593,6 +592,6 @@ export default function register(api) {
|
|
|
593
592
|
|
|
594
593
|
log("已注册: fetch拦截器(全渠道) + before_tool_call + message_sending + llm_output + message_sent");
|
|
595
594
|
log("═══════════════════════════════════════════════════════");
|
|
596
|
-
log("
|
|
595
|
+
log(" 安全插件 v2.0 启动完成");
|
|
597
596
|
log("═══════════════════════════════════════════════════════");
|
|
598
597
|
}
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "mobook-security-plugin",
|
|
3
3
|
"name": "MoBook 安全防护插件",
|
|
4
|
-
"version": "2.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"description": "MoBook 企业级安全插件 - 危险命令分级拦截、敏感信息全渠道脱敏(身份证GB11643/银行卡Luhn校验)、LLM响应拦截、操作审计",
|
|
6
6
|
"entry": "./index.js",
|
|
7
7
|
"type": "plugin",
|
|
8
8
|
"configSchema": {}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcrays/mobook-security-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "MoBook 企业级安全插件 - 危险命令分级拦截、敏感信息全渠道脱敏(身份证GB11643/银行卡Luhn校验)、LLM响应拦截、操作审计",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"openclaw.plugin.json"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
7
15
|
"openclaw": {
|
|
8
16
|
"type": "plugin",
|
|
9
17
|
"id": "mobook-security-plugin",
|