mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:07:41 +00:00
refactor: harden safe-bin trusted dir diagnostics
This commit is contained in:
@@ -438,6 +438,50 @@ describe("security audit", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("warns for risky safeBinTrustedDirs entries", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
tools: {
|
||||
exec: {
|
||||
safeBinTrustedDirs: ["/usr/local/bin", "/tmp/openclaw-safe-bins"],
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
list: [
|
||||
{
|
||||
id: "ops",
|
||||
tools: {
|
||||
exec: {
|
||||
safeBinTrustedDirs: ["./relative-bin-dir"],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const res = await audit(cfg);
|
||||
const finding = res.findings.find(
|
||||
(f) => f.checkId === "tools.exec.safe_bin_trusted_dirs_risky",
|
||||
);
|
||||
expect(finding?.severity).toBe("warn");
|
||||
expect(finding?.detail).toContain("/usr/local/bin");
|
||||
expect(finding?.detail).toContain("/tmp/openclaw-safe-bins");
|
||||
expect(finding?.detail).toContain("agents.list.ops.tools.exec");
|
||||
});
|
||||
|
||||
it("does not warn for non-risky absolute safeBinTrustedDirs entries", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
tools: {
|
||||
exec: {
|
||||
safeBinTrustedDirs: ["/usr/libexec"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const res = await audit(cfg);
|
||||
expectNoFinding(res, "tools.exec.safe_bin_trusted_dirs_risky");
|
||||
});
|
||||
|
||||
it("evaluates loopback control UI and logging exposure findings", async () => {
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
|
||||
Reference in New Issue
Block a user