mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:01:24 +00:00
fix(security): block safeBins shell expansion
This commit is contained in:
@@ -5,6 +5,7 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
analyzeArgvCommand,
|
||||
analyzeShellCommand,
|
||||
buildSafeShellCommand,
|
||||
evaluateExecAllowlist,
|
||||
evaluateShellAllowlist,
|
||||
isSafeBinUsage,
|
||||
@@ -78,6 +79,25 @@ describe("exec approvals allowlist matching", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("exec approvals safe shell command builder", () => {
|
||||
it("single-quotes argv tokens while preserving pipes/chaining", () => {
|
||||
if (process.platform === "win32") {
|
||||
return;
|
||||
}
|
||||
const res = buildSafeShellCommand({
|
||||
command: 'head $FOO | grep * && echo "a\'b" ; wc -l',
|
||||
platform: process.platform,
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.command).toContain("'$FOO'");
|
||||
expect(res.command).toContain("'*'");
|
||||
expect(res.command).toContain("&&");
|
||||
expect(res.command).toContain(";");
|
||||
expect(res.command).toContain("|");
|
||||
expect(res.command).toContain("'a'\"'\"'b'");
|
||||
});
|
||||
});
|
||||
|
||||
describe("exec approvals command resolution", () => {
|
||||
it("resolves PATH executables", () => {
|
||||
const dir = makeTempDir();
|
||||
|
||||
Reference in New Issue
Block a user