mirror of https://github.com/openclaw/openclaw.git
test: tighten safe bin policy coverage
This commit is contained in:
parent
2e409da274
commit
699ac5ab12
|
|
@ -53,6 +53,12 @@ describe("exec safe bin policy sort", () => {
|
|||
expect(validateSafeBinArgv(["--ke=1,1"], sortProfile)).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects missing or path-like values for allowed flags", () => {
|
||||
expect(validateSafeBinArgv(["--key"], sortProfile)).toBe(false);
|
||||
expect(validateSafeBinArgv(["--key", "./fields.txt"], sortProfile)).toBe(false);
|
||||
expect(validateSafeBinArgv(["-S", "C:\\temp\\buffer"], sortProfile)).toBe(false);
|
||||
});
|
||||
|
||||
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);
|
||||
|
|
@ -78,6 +84,19 @@ describe("exec safe bin policy wc", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("exec safe bin policy token hygiene", () => {
|
||||
it("rejects path-like and glob positional tokens after the terminator", () => {
|
||||
const grepProfile = SAFE_BIN_PROFILES.grep;
|
||||
expect(validateSafeBinArgv(["-e", "needle", "--", "../secret.txt"], grepProfile)).toBe(false);
|
||||
expect(validateSafeBinArgv(["-e", "needle", "--", "*.txt"], grepProfile)).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps stdin marker after the terminator non-positional", () => {
|
||||
const grepProfile = SAFE_BIN_PROFILES.grep;
|
||||
expect(validateSafeBinArgv(["-e", "needle", "--", "-"], grepProfile)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("exec safe bin policy long-option metadata", () => {
|
||||
it("precomputes long-option prefix mappings for compiled profiles", () => {
|
||||
const sortProfile = SAFE_BIN_PROFILES.sort;
|
||||
|
|
|
|||
Loading…
Reference in New Issue