mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
test(security): cover denyCommands suggestion output
This commit is contained in:
@@ -1156,6 +1156,45 @@ description: test skill
|
||||
expect(finding?.severity).toBe("warn");
|
||||
expect(finding?.detail).toContain("system.*");
|
||||
expect(finding?.detail).toContain("system.runx");
|
||||
expect(finding?.detail).toContain("did you mean");
|
||||
expect(finding?.detail).toContain("system.run");
|
||||
});
|
||||
|
||||
it("suggests prefix-matching commands for unknown denyCommands entries", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
gateway: {
|
||||
nodes: {
|
||||
denyCommands: ["system.run.prep"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const res = await audit(cfg);
|
||||
const finding = res.findings.find(
|
||||
(f) => f.checkId === "gateway.nodes.deny_commands_ineffective",
|
||||
);
|
||||
expect(finding?.severity).toBe("warn");
|
||||
expect(finding?.detail).toContain("system.run.prep");
|
||||
expect(finding?.detail).toContain("did you mean");
|
||||
expect(finding?.detail).toContain("system.run.prepare");
|
||||
});
|
||||
|
||||
it("keeps unknown denyCommands entries without suggestions when no close command exists", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
gateway: {
|
||||
nodes: {
|
||||
denyCommands: ["zzzzzzzzzzzzzz"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const res = await audit(cfg);
|
||||
const finding = res.findings.find(
|
||||
(f) => f.checkId === "gateway.nodes.deny_commands_ineffective",
|
||||
);
|
||||
expect(finding?.severity).toBe("warn");
|
||||
expect(finding?.detail).toContain("zzzzzzzzzzzzzz");
|
||||
expect(finding?.detail).not.toContain("did you mean");
|
||||
});
|
||||
|
||||
it("scores dangerous gateway.nodes.allowCommands by exposure", async () => {
|
||||
|
||||
Reference in New Issue
Block a user