fix(exec): clarify and cover auto host override guard

This commit is contained in:
Vincent Koc
2026-04-01 18:26:07 +09:00
committed by Peter Steinberger
parent dae6632da1
commit 5dca81271c
2 changed files with 28 additions and 1 deletions

View File

@@ -57,6 +57,33 @@ describe("resolveExecTarget", () => {
}),
).toThrow("exec host not allowed");
});
it("also rejects gateway override when configured host is auto", () => {
expect(() =>
resolveExecTarget({
configuredTarget: "auto",
requestedTarget: "gateway",
elevatedRequested: false,
sandboxAvailable: true,
}),
).toThrow("exec host not allowed");
});
it("allows explicit auto request when configured host is auto", () => {
expect(
resolveExecTarget({
configuredTarget: "auto",
requestedTarget: "auto",
elevatedRequested: false,
sandboxAvailable: true,
}),
).toMatchObject({
configuredTarget: "auto",
requestedTarget: "auto",
selectedTarget: "auto",
effectiveHost: "sandbox",
});
});
});
describe("emitExecSystemEvent", () => {

View File

@@ -249,7 +249,7 @@ export function resolveExecTarget(params: {
) {
throw new Error(
`exec host not allowed (requested ${renderExecTargetLabel(requestedTarget)}; ` +
`configure tools.exec.host=${renderExecTargetLabel(configuredTarget)} to allow).`,
`configure tools.exec.host=${renderExecTargetLabel(requestedTarget)} to allow).`,
);
}
const selectedTarget = requestedTarget ?? configuredTarget;