mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:51:25 +00:00
fix: block safeBins sort --compress-program bypass
This commit is contained in:
@@ -564,6 +564,22 @@ describe("exec approvals safe bins", () => {
|
||||
safeBins: ["sort"],
|
||||
executableName: "sort",
|
||||
},
|
||||
{
|
||||
name: "blocks sort external program flag via --compress-program=<prog>",
|
||||
argv: ["sort", "--compress-program=sh"],
|
||||
resolvedPath: "/usr/bin/sort",
|
||||
expected: false,
|
||||
safeBins: ["sort"],
|
||||
executableName: "sort",
|
||||
},
|
||||
{
|
||||
name: "blocks sort external program flag via --compress-program <prog>",
|
||||
argv: ["sort", "--compress-program", "sh"],
|
||||
resolvedPath: "/usr/bin/sort",
|
||||
expected: false,
|
||||
safeBins: ["sort"],
|
||||
executableName: "sort",
|
||||
},
|
||||
{
|
||||
name: "blocks grep recursive flags that read cwd",
|
||||
argv: ["grep", "-R", "needle"],
|
||||
|
||||
@@ -20,3 +20,17 @@ describe("exec safe bin policy grep", () => {
|
||||
expect(validateSafeBinArgv(["-e", "KEY", "--", ".env"], grepProfile)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("exec safe bin policy sort", () => {
|
||||
const sortProfile = SAFE_BIN_PROFILES.sort;
|
||||
|
||||
it("allows stdin-only sort flags", () => {
|
||||
expect(validateSafeBinArgv(["-S", "1M"], sortProfile)).toBe(true);
|
||||
expect(validateSafeBinArgv(["--key=1,1"], sortProfile)).toBe(true);
|
||||
});
|
||||
|
||||
it("blocks sort --compress-program in safe-bin mode", () => {
|
||||
expect(validateSafeBinArgv(["--compress-program=sh"], sortProfile)).toBe(false);
|
||||
expect(validateSafeBinArgv(["--compress-program", "sh"], sortProfile)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -151,7 +151,6 @@ export const SAFE_BIN_PROFILE_FIXTURES: Record<string, SafeBinProfileFixture> =
|
||||
"--field-separator",
|
||||
"--buffer-size",
|
||||
"--temporary-directory",
|
||||
"--compress-program",
|
||||
"--parallel",
|
||||
"--batch-size",
|
||||
"--random-source",
|
||||
@@ -163,7 +162,8 @@ export const SAFE_BIN_PROFILE_FIXTURES: Record<string, SafeBinProfileFixture> =
|
||||
"-T",
|
||||
"-o",
|
||||
],
|
||||
blockedFlags: ["--files0-from", "--output", "-o"],
|
||||
// --compress-program can invoke an external executable and breaks stdin-only guarantees.
|
||||
blockedFlags: ["--compress-program", "--files0-from", "--output", "-o"],
|
||||
},
|
||||
uniq: {
|
||||
maxPositional: 0,
|
||||
|
||||
Reference in New Issue
Block a user