mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:31:24 +00:00
23 lines
1.0 KiB
TypeScript
23 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { SAFE_BIN_PROFILES, validateSafeBinArgv } from "./exec-safe-bin-policy.js";
|
|
|
|
describe("exec safe bin policy grep", () => {
|
|
const grepProfile = SAFE_BIN_PROFILES.grep;
|
|
|
|
it("allows stdin-only grep when pattern comes from flags", () => {
|
|
expect(validateSafeBinArgv(["-e", "needle"], grepProfile)).toBe(true);
|
|
expect(validateSafeBinArgv(["--regexp=needle"], grepProfile)).toBe(true);
|
|
});
|
|
|
|
it("blocks grep positional pattern form to avoid filename ambiguity", () => {
|
|
expect(validateSafeBinArgv(["needle"], grepProfile)).toBe(false);
|
|
});
|
|
|
|
it("blocks file positionals when pattern comes from -e/--regexp", () => {
|
|
expect(validateSafeBinArgv(["-e", "SECRET", ".env"], grepProfile)).toBe(false);
|
|
expect(validateSafeBinArgv(["--regexp", "KEY", "config.py"], grepProfile)).toBe(false);
|
|
expect(validateSafeBinArgv(["--regexp=KEY", ".env"], grepProfile)).toBe(false);
|
|
expect(validateSafeBinArgv(["-e", "KEY", "--", ".env"], grepProfile)).toBe(false);
|
|
});
|
|
});
|