mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-17 13:00:48 +00:00
Status: lazy-load security audit commands
This commit is contained in:
@@ -2,17 +2,22 @@ import { callGateway } from "../gateway/call.js";
|
||||
import type { HeartbeatEventPayload } from "../infra/heartbeat-events.js";
|
||||
import { normalizeUpdateChannel, resolveUpdateChannelDisplay } from "../infra/update-channels.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { runSecurityAudit } from "../security/audit.js";
|
||||
import { getDaemonStatusSummary, getNodeDaemonStatusSummary } from "./status.daemon.js";
|
||||
import { scanStatus } from "./status.scan.js";
|
||||
|
||||
let providerUsagePromise: Promise<typeof import("../infra/provider-usage.js")> | undefined;
|
||||
let securityAuditModulePromise: Promise<typeof import("../security/audit.runtime.js")> | undefined;
|
||||
|
||||
function loadProviderUsage() {
|
||||
providerUsagePromise ??= import("../infra/provider-usage.js");
|
||||
return providerUsagePromise;
|
||||
}
|
||||
|
||||
function loadSecurityAuditModule() {
|
||||
securityAuditModulePromise ??= import("../security/audit.runtime.js");
|
||||
return securityAuditModulePromise;
|
||||
}
|
||||
|
||||
export async function statusJsonCommand(
|
||||
opts: {
|
||||
deep?: boolean;
|
||||
@@ -23,13 +28,15 @@ export async function statusJsonCommand(
|
||||
runtime: RuntimeEnv,
|
||||
) {
|
||||
const scan = await scanStatus({ json: true, timeoutMs: opts.timeoutMs, all: opts.all }, runtime);
|
||||
const securityAudit = await runSecurityAudit({
|
||||
config: scan.cfg,
|
||||
sourceConfig: scan.sourceConfig,
|
||||
deep: false,
|
||||
includeFilesystem: true,
|
||||
includeChannelSecurity: true,
|
||||
});
|
||||
const securityAudit = await loadSecurityAuditModule().then(({ runSecurityAudit }) =>
|
||||
runSecurityAudit({
|
||||
config: scan.cfg,
|
||||
sourceConfig: scan.sourceConfig,
|
||||
deep: false,
|
||||
includeFilesystem: true,
|
||||
includeChannelSecurity: true,
|
||||
}),
|
||||
);
|
||||
|
||||
const usage = opts.usage
|
||||
? await loadProviderUsage().then(({ loadProviderUsageSummary }) =>
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
type Tone,
|
||||
} from "../memory/status-format.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { runSecurityAudit } from "../security/audit.js";
|
||||
import { getTerminalTableWidth, renderTable } from "../terminal/table.js";
|
||||
import { theme } from "../terminal/theme.js";
|
||||
import { formatHealthChannelLines, type HealthSummary } from "./health.js";
|
||||
@@ -37,12 +36,18 @@ import {
|
||||
} from "./status.update.js";
|
||||
|
||||
let providerUsagePromise: Promise<typeof import("../infra/provider-usage.js")> | undefined;
|
||||
let securityAuditModulePromise: Promise<typeof import("../security/audit.runtime.js")> | undefined;
|
||||
|
||||
function loadProviderUsage() {
|
||||
providerUsagePromise ??= import("../infra/provider-usage.js");
|
||||
return providerUsagePromise;
|
||||
}
|
||||
|
||||
function loadSecurityAuditModule() {
|
||||
securityAuditModulePromise ??= import("../security/audit.runtime.js");
|
||||
return securityAuditModulePromise;
|
||||
}
|
||||
|
||||
function resolvePairingRecoveryContext(params: {
|
||||
error?: string | null;
|
||||
closeReason?: string | null;
|
||||
@@ -90,28 +95,25 @@ export async function statusCommand(
|
||||
{ json: opts.json, timeoutMs: opts.timeoutMs, all: opts.all },
|
||||
runtime,
|
||||
);
|
||||
const securityAudit = opts.json
|
||||
? await runSecurityAudit({
|
||||
const runSecurityAudit = async () =>
|
||||
await loadSecurityAuditModule().then(({ runSecurityAudit }) =>
|
||||
runSecurityAudit({
|
||||
config: scan.cfg,
|
||||
sourceConfig: scan.sourceConfig,
|
||||
deep: false,
|
||||
includeFilesystem: true,
|
||||
includeChannelSecurity: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
const securityAudit = opts.json
|
||||
? await runSecurityAudit()
|
||||
: await withProgress(
|
||||
{
|
||||
label: "Running security audit…",
|
||||
indeterminate: true,
|
||||
enabled: true,
|
||||
},
|
||||
async () =>
|
||||
await runSecurityAudit({
|
||||
config: scan.cfg,
|
||||
sourceConfig: scan.sourceConfig,
|
||||
deep: false,
|
||||
includeFilesystem: true,
|
||||
includeChannelSecurity: true,
|
||||
}),
|
||||
async () => await runSecurityAudit(),
|
||||
);
|
||||
const {
|
||||
cfg,
|
||||
|
||||
1
src/security/audit.runtime.ts
Normal file
1
src/security/audit.runtime.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { runSecurityAudit } from "./audit.js";
|
||||
Reference in New Issue
Block a user