mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-22 07:20:59 +00:00
Security: lazy-load deep skill audit helpers
This commit is contained in:
@@ -11,7 +11,6 @@ import { SANDBOX_BROWSER_SECURITY_HASH_EPOCH } from "../agents/sandbox/constants
|
||||
import { execDockerRaw, type ExecDockerRawResult } from "../agents/sandbox/docker.js";
|
||||
import { resolveSandboxToolPolicyForAgent } from "../agents/sandbox/tool-policy.js";
|
||||
import type { SandboxToolPolicy } from "../agents/sandbox/types.js";
|
||||
import { loadWorkspaceSkillEntries } from "../agents/skills.js";
|
||||
import { isToolAllowedByPolicies } from "../agents/tool-policy-match.js";
|
||||
import { resolveToolProfilePolicy } from "../agents/tool-policy.js";
|
||||
import { listAgentWorkspaceDirs } from "../agents/workspace-dirs.js";
|
||||
@@ -54,6 +53,12 @@ type ExecDockerRawFn = (
|
||||
type CodeSafetySummaryCache = Map<string, Promise<unknown>>;
|
||||
const MAX_WORKSPACE_SKILL_SCAN_FILES_PER_WORKSPACE = 2_000;
|
||||
const MAX_WORKSPACE_SKILL_ESCAPE_DETAIL_ROWS = 12;
|
||||
let skillsModulePromise: Promise<typeof import("../agents/skills.js")> | undefined;
|
||||
|
||||
function loadSkillsModule() {
|
||||
skillsModulePromise ??= import("../agents/skills.js");
|
||||
return skillsModulePromise;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Helpers
|
||||
@@ -1245,6 +1250,7 @@ export async function collectInstalledSkillsCodeSafetyFindings(params: {
|
||||
const pluginExtensionsDir = path.join(params.stateDir, "extensions");
|
||||
const scannedSkillDirs = new Set<string>();
|
||||
const workspaceDirs = listAgentWorkspaceDirs(params.cfg);
|
||||
const { loadWorkspaceSkillEntries } = await loadSkillsModule();
|
||||
|
||||
for (const workspaceDir of workspaceDirs) {
|
||||
const entries = loadWorkspaceSkillEntries(workspaceDir, { config: params.cfg });
|
||||
|
||||
Reference in New Issue
Block a user