

























@@ -1,7 +1,7 @@
11import path from "node:path";
22import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
33import { resolveSandboxConfigForAgent } from "../agents/sandbox/config.js";
4-import type { listChannelPlugins } from "../channels/plugins/index.js";
4+import type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
55import type { ConfigFileSnapshot, OpenClawConfig } from "../config/config.js";
66import { resolveConfigPath, resolveStateDir } from "../config/paths.js";
77import { type ExecApprovalsFile, loadExecApprovals } from "../infra/exec-approvals.js";
@@ -57,7 +57,7 @@ export type SecurityAuditOptions = {
5757/** Time limit for deep gateway probe. */
5858deepTimeoutMs?: number;
5959/** Dependency injection for tests. */
60-plugins?: ReturnType<typeof listChannelPlugins>;
60+plugins?: ChannelPlugin[];
6161/** Dependency injection for tests (Windows ACL checks). */
6262execIcacls?: ExecFn;
6363/** Dependency injection for tests (Docker label checks). */
@@ -88,21 +88,20 @@ export type AuditExecutionContext = {
8888execIcacls?: ExecFn;
8989execDockerRawFn?: ExecDockerRawFn;
9090probeGatewayFn?: ProbeGatewayFn;
91-plugins?: ReturnType<typeof listChannelPlugins>;
91+plugins?: ChannelPlugin[];
9292configSnapshot: ConfigFileSnapshot | null;
9393codeSafetySummaryCache: Map<string, Promise<unknown>>;
9494deepProbeAuth?: { token?: string; password?: string };
9595workspaceDir?: string;
9696};
979798-let channelPluginsModulePromise: Promise<typeof import("../channels/plugins/index.js")> | undefined;
98+let readOnlyChannelPluginsModulePromise:
99+| Promise<typeof import("../channels/plugins/read-only.js")>
100+| undefined;
99101let auditNonDeepModulePromise: Promise<typeof import("./audit.nondeep.runtime.js")> | undefined;
100102let auditChannelModulePromise:
101103| Promise<typeof import("./audit-channel.collect.runtime.js")>
102104| undefined;
103-let pluginRegistryLoaderModulePromise:
104-| Promise<typeof import("../plugins/runtime/runtime-registry-loader.js")>
105-| undefined;
106105let pluginMetadataRegistryLoaderModulePromise:
107106| Promise<typeof import("../plugins/runtime/metadata-registry-loader.js")>
108107| undefined;
@@ -122,9 +121,9 @@ let gatewayProbeDepsPromise:
122121}>
123122| undefined;
124123125-async function loadChannelPlugins() {
126-channelPluginsModulePromise ??= import("../channels/plugins/index.js");
127-return await channelPluginsModulePromise;
124+async function loadReadOnlyChannelPlugins() {
125+readOnlyChannelPluginsModulePromise ??= import("../channels/plugins/read-only.js");
126+return await readOnlyChannelPluginsModulePromise;
128127}
129128130129async function loadAuditNonDeepModule() {
@@ -137,11 +136,6 @@ async function loadAuditChannelModule() {
137136return await auditChannelModulePromise;
138137}
139138140-async function loadPluginRegistryLoaderModule() {
141-pluginRegistryLoaderModulePromise ??= import("../plugins/runtime/runtime-registry-loader.js");
142-return await pluginRegistryLoaderModulePromise;
143-}
144-145139async function loadPluginMetadataRegistryLoaderModule() {
146140pluginMetadataRegistryLoaderModulePromise ??=
147141import("../plugins/runtime/metadata-registry-loader.js");
@@ -1050,16 +1044,16 @@ export async function runSecurityAudit(opts: SecurityAuditOptions): Promise<Secu
10501044}
10511045}
10521046if (shouldAuditChannelSecurity) {
1053-if (context.plugins === undefined) {
1054-(await loadPluginRegistryLoaderModule()).ensurePluginRegistryLoaded({
1055-scope: "configured-channels",
1056-config: cfg,
1047+const channelPlugins =
1048+context.plugins ??
1049+(await loadReadOnlyChannelPlugins()).listReadOnlyChannelPluginsForConfig(cfg, {
10571050activationSourceConfig: context.sourceConfig,
10581051workspaceDir: context.workspaceDir,
10591052 env,
1053+ stateDir,
1054+includePersistedAuthState: true,
1055+includeSetupRuntimeFallback: false,
10601056});
1061-}
1062-const channelPlugins = context.plugins ?? (await loadChannelPlugins()).listChannelPlugins();
10631057const { collectChannelSecurityFindings } = await loadAuditChannelModule();
10641058findings.push(
10651059 ...(await collectChannelSecurityFindings({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。