openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
53 lines (52 loc) • 1.81 kB
JavaScript
import { n as listAgentEntries } from "./agent-roster-t1ooUdXp.mjs";
import "./agent-scope-config-DmXgFGKP.mjs";
import { o as isToolAllowedByPolicies } from "./tool-policy-match-DzwVnbV4.mjs";
import { i as resolveSandboxConfigForAgent } from "./config-WbZbWrF1.mjs";
import { t as resolveConfiguredToolPolicies } from "./agent-tools.policy-CM-3Smt9.mjs";
//#region src/security/exec-filesystem-policy.ts
const MUTATING_FS_TOOLS = [
"write",
"edit",
"apply_patch"
];
const RUNTIME_TOOLS = ["exec", "process"];
/** Find policy scopes where exec can still mutate files despite disabled fs tools. */
function collectExecFilesystemPolicyDriftHits(e) {
const t = [];
const n = e.tools?.exec;
const r = [{ scopeLabel: "tools" }];
for (const t of listAgentEntries(e)) {
if (!t || typeof t !== "object" || typeof t.id !== "string") continue;
r.push({
scopeLabel: `agents.entries.${t.id}.tools`,
agentId: t.id,
tools: t.tools
});
}
for (const i of r) {
const r = resolveSandboxConfigForAgent(e, i.agentId);
const a = i.tools?.exec?.host ?? n?.host ?? "auto";
if (r.mode === "all" && a !== "gateway" && a !== "node" && r.workspaceAccess !== "rw") continue;
const o = resolveConfiguredToolPolicies({
cfg: e,
agentTools: i.tools,
sandboxMode: r.mode,
agentId: i.agentId
});
const s = RUNTIME_TOOLS.filter((e) => isToolAllowedByPolicies(e, o));
if (!s.includes("exec")) continue;
const c = MUTATING_FS_TOOLS.filter((e) => !isToolAllowedByPolicies(e, o));
if (c.length !== MUTATING_FS_TOOLS.length) continue;
t.push({
scopeLabel: i.scopeLabel,
runtimeTools: s,
disabledFilesystemTools: c,
sandboxMode: r.mode,
sandboxWorkspaceAccess: r.workspaceAccess,
execHost: a
});
}
return t;
}
//#endregion
export { collectExecFilesystemPolicyDriftHits as t };