mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 13:20:21 +00:00
infra: unwrap script wrapper approval targets (#55685)
* infra: unwrap script wrapper approvals * infra: handle script short option values * infra: gate script wrapper unwrapping by platform * infra: narrow script wrapper option parsing
This commit is contained in:
@@ -13,6 +13,10 @@ import {
|
||||
unwrapKnownShellMultiplexerInvocation,
|
||||
} from "./exec-wrapper-resolution.js";
|
||||
|
||||
function supportsScriptPositionalCommandForTests(): boolean {
|
||||
return process.platform === "darwin" || process.platform === "freebsd";
|
||||
}
|
||||
|
||||
describe("basenameLower", () => {
|
||||
test.each([
|
||||
{ token: " Bun.CMD ", expected: "bun.cmd" },
|
||||
@@ -40,6 +44,7 @@ describe("normalizeExecutableToken", () => {
|
||||
describe("wrapper classification", () => {
|
||||
test.each([
|
||||
{ token: "sudo", dispatch: true, shell: false },
|
||||
{ token: "script", dispatch: true, shell: false },
|
||||
{ token: "time", dispatch: true, shell: false },
|
||||
{ token: "timeout.exe", dispatch: true, shell: false },
|
||||
{ token: "bash", dispatch: false, shell: true },
|
||||
@@ -119,6 +124,16 @@ describe("unwrapKnownDispatchWrapperInvocation", () => {
|
||||
argv: ["nohup", "--", "bash", "-lc", "echo hi"],
|
||||
expected: { kind: "unwrapped", wrapper: "nohup", argv: ["bash", "-lc", "echo hi"] },
|
||||
},
|
||||
{
|
||||
argv: ["script", "-q", "/dev/null", "bash", "-lc", "echo hi"],
|
||||
expected: supportsScriptPositionalCommandForTests()
|
||||
? { kind: "unwrapped", wrapper: "script", argv: ["bash", "-lc", "echo hi"] }
|
||||
: { kind: "blocked", wrapper: "script" },
|
||||
},
|
||||
{
|
||||
argv: ["script", "-E", "always", "/dev/null", "bash", "-lc", "echo hi"],
|
||||
expected: { kind: "blocked", wrapper: "script" },
|
||||
},
|
||||
{
|
||||
argv: ["stdbuf", "-o", "L", "bash", "-lc", "echo hi"],
|
||||
expected: { kind: "unwrapped", wrapper: "stdbuf", argv: ["bash", "-lc", "echo hi"] },
|
||||
@@ -131,6 +146,10 @@ describe("unwrapKnownDispatchWrapperInvocation", () => {
|
||||
argv: ["timeout", "--signal=TERM", "5s", "bash", "-lc", "echo hi"],
|
||||
expected: { kind: "unwrapped", wrapper: "timeout", argv: ["bash", "-lc", "echo hi"] },
|
||||
},
|
||||
{
|
||||
argv: ["script", "-q", "/dev/null"],
|
||||
expected: { kind: "blocked", wrapper: "script" },
|
||||
},
|
||||
{
|
||||
argv: ["sudo", "bash", "-lc", "echo hi"],
|
||||
expected: { kind: "blocked", wrapper: "sudo" },
|
||||
|
||||
Reference in New Issue
Block a user