mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 14:20:22 +00:00
fix(exec): default implicit target to auto
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
minSecurity,
|
||||
normalizeExecAsk,
|
||||
normalizeExecHost,
|
||||
normalizeExecTarget,
|
||||
normalizeExecSecurity,
|
||||
requiresExecApproval,
|
||||
} from "./exec-approvals.js";
|
||||
@@ -18,6 +19,16 @@ describe("exec approvals policy helpers", () => {
|
||||
expect(normalizeExecHost(raw)).toBe(expected);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ raw: " auto ", expected: "auto" },
|
||||
{ raw: " gateway ", expected: "gateway" },
|
||||
{ raw: "NODE", expected: "node" },
|
||||
{ raw: "", expected: null },
|
||||
{ raw: "ssh", expected: null },
|
||||
])("normalizes exec target value %j", ({ raw, expected }) => {
|
||||
expect(normalizeExecTarget(raw)).toBe(expected);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ raw: " allowlist ", expected: "allowlist" },
|
||||
{ raw: "FULL", expected: "full" },
|
||||
|
||||
@@ -8,6 +8,7 @@ export * from "./exec-approvals-analysis.js";
|
||||
export * from "./exec-approvals-allowlist.js";
|
||||
|
||||
export type ExecHost = "sandbox" | "gateway" | "node";
|
||||
export type ExecTarget = "auto" | ExecHost;
|
||||
export type ExecSecurity = "deny" | "allowlist" | "full";
|
||||
export type ExecAsk = "off" | "on-miss" | "always";
|
||||
|
||||
@@ -19,6 +20,14 @@ export function normalizeExecHost(value?: string | null): ExecHost | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function normalizeExecTarget(value?: string | null): ExecTarget | null {
|
||||
const normalized = value?.trim().toLowerCase();
|
||||
if (normalized === "auto") {
|
||||
return normalized;
|
||||
}
|
||||
return normalizeExecHost(normalized);
|
||||
}
|
||||
|
||||
export function normalizeExecSecurity(value?: string | null): ExecSecurity | null {
|
||||
const normalized = value?.trim().toLowerCase();
|
||||
if (normalized === "deny" || normalized === "allowlist" || normalized === "full") {
|
||||
|
||||
Reference in New Issue
Block a user