@dcrays/mobook-security-plugin 2.0.7 → 2.0.8
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 +6 -20
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -437,7 +437,6 @@ function installFetchInterceptor(api) {
|
|
|
437
437
|
const reqHeaders = getMergedRequestHeaders(input, init);
|
|
438
438
|
const reqBodyText = await getRequestBodyText(input, init);
|
|
439
439
|
|
|
440
|
-
log(`[LLM-REQ #${thisCallId}] ${method} ${url}`, "DEBUG");
|
|
441
440
|
|
|
442
441
|
// ---- 请求侧检查:提示词注入检测(已禁用) ----
|
|
443
442
|
// const promptInjectionPatterns = [
|
|
@@ -480,7 +479,6 @@ function installFetchInterceptor(api) {
|
|
|
480
479
|
|
|
481
480
|
const respText = extractTextFromResponseBody(respBody, sse);
|
|
482
481
|
if (!respText) {
|
|
483
|
-
log(`[LLM-RESP #${thisCallId}] ${resp.status} ${durationMs}ms (empty body)`, "DEBUG");
|
|
484
482
|
return resp;
|
|
485
483
|
}
|
|
486
484
|
|
|
@@ -494,7 +492,6 @@ function installFetchInterceptor(api) {
|
|
|
494
492
|
return makeBlockedResponse(sse, finalText, resp);
|
|
495
493
|
}
|
|
496
494
|
|
|
497
|
-
log(`[LLM-RESP #${thisCallId}] ${resp.status} ${durationMs}ms (clean)`, "DEBUG");
|
|
498
495
|
return resp;
|
|
499
496
|
};
|
|
500
497
|
|
|
@@ -511,11 +508,7 @@ function installFetchInterceptor(api) {
|
|
|
511
508
|
// 插件注册
|
|
512
509
|
// ============================================================
|
|
513
510
|
export default function register(api) {
|
|
514
|
-
log("
|
|
515
|
-
log(" MoBook 安全防护插件 v2.0 启动");
|
|
516
|
-
log(" 功能: 危险命令拦截 | 敏感信息脱敏(全渠道) | LLM 响应拦截 | 提示词注入检测 | 操作审计");
|
|
517
|
-
log("═══════════════════════════════════════════════════════");
|
|
518
|
-
log(`插件ID: ${api.id}`);
|
|
511
|
+
log("MoBook 安全防护插件 v2.0 启动");
|
|
519
512
|
|
|
520
513
|
// ---- 安装 Fetch 拦截器(核心:全渠道 LLM 拦截) ----
|
|
521
514
|
installFetchInterceptor(api);
|
|
@@ -526,8 +519,6 @@ export default function register(api) {
|
|
|
526
519
|
const params = event?.params || {};
|
|
527
520
|
const safeParams = sanitizeParamsForLog(params);
|
|
528
521
|
|
|
529
|
-
log(`TOOL_CALL: tool=${toolName} params=${JSON.stringify(safeParams).slice(0, 500)}`);
|
|
530
|
-
|
|
531
522
|
// exec 命令安全检查
|
|
532
523
|
if (toolName === "exec") {
|
|
533
524
|
const cmd = params.command || "";
|
|
@@ -599,7 +590,7 @@ export default function register(api) {
|
|
|
599
590
|
blockReason: "🛡️ 安全插件拦截:该目录为受保护资源,禁止访问"
|
|
600
591
|
};
|
|
601
592
|
}
|
|
602
|
-
|
|
593
|
+
|
|
603
594
|
}
|
|
604
595
|
}
|
|
605
596
|
|
|
@@ -632,7 +623,7 @@ export default function register(api) {
|
|
|
632
623
|
const pathValues = [params.path || "", params.command || "", params.file || ""].join(" ");
|
|
633
624
|
const isConfigFile = /openclaw\.json/.test(pathValues);
|
|
634
625
|
if (isConfigFile) {
|
|
635
|
-
|
|
626
|
+
|
|
636
627
|
// 检查内容是否涉及禁用安全插件
|
|
637
628
|
const contentValues = [
|
|
638
629
|
params.command || "",
|
|
@@ -679,15 +670,10 @@ export default function register(api) {
|
|
|
679
670
|
}
|
|
680
671
|
});
|
|
681
672
|
|
|
682
|
-
// ---- Hook 4: message_sent
|
|
673
|
+
// ---- Hook 4: message_sent(仅记录,不再写日志) ----
|
|
683
674
|
api.on("message_sent", async (event, ctx) => {
|
|
684
|
-
|
|
685
|
-
const to = event?.to || "unknown";
|
|
686
|
-
log(`MESSAGE_SENT: channel=${channel} to=${to}`);
|
|
675
|
+
// 静默——只保留 hook 注册,不记录常规发送日志
|
|
687
676
|
});
|
|
688
677
|
|
|
689
|
-
log("
|
|
690
|
-
log("═══════════════════════════════════════════════════════");
|
|
691
|
-
log(" 安全插件 v2.0 启动完成");
|
|
692
|
-
log("═══════════════════════════════════════════════════════");
|
|
678
|
+
log("启动完成: fetch拦截器 + before_tool_call + message_sending + llm_output + message_sent");
|
|
693
679
|
}
|
package/openclaw.plugin.json
CHANGED