fix(exec): inherit ask from exec-approvals.json when tools.exec.ask unset

Landed from contributor PR #29187 by @Bartok9.

Co-authored-by: Bartok9 <259807879+Bartok9@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-03-08 00:34:55 +00:00
parent 240b143bde
commit c6575891c7
5 changed files with 105 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ import {
type ExecApprovalsFile,
type ExecAsk,
type ExecSecurity,
loadExecApprovals,
maxAsk,
minSecurity,
normalizeExecAsk,
@@ -96,7 +97,9 @@ function resolveNodesRunPolicy(opts: NodesRunOpts, execDefaults: ExecDefaults |
if (opts.security && !requestedSecurity) {
throw new Error("invalid --security (use deny|allowlist|full)");
}
const configuredAsk = normalizeExecAsk(execDefaults?.ask) ?? "on-miss";
// Keep local exec defaults in sync with exec-approvals.json when tools.exec.ask is unset.
const configuredAsk =
normalizeExecAsk(execDefaults?.ask) ?? loadExecApprovals().defaults?.ask ?? "on-miss";
const requestedAsk = normalizeExecAsk(opts.ask);
if (opts.ask && !requestedAsk) {
throw new Error("invalid --ask (use off|on-miss|always)");