diff --git a/src/infra/exec-approvals-allowlist.ts b/src/infra/exec-approvals-allowlist.ts index cb491937df5..1d7b52018ec 100644 --- a/src/infra/exec-approvals-allowlist.ts +++ b/src/infra/exec-approvals-allowlist.ts @@ -256,6 +256,14 @@ export function evaluateShellAllowlist(params: { autoAllowSkills?: boolean; platform?: string | null; }): ExecAllowlistAnalysis { + const analysisFailure = (): ExecAllowlistAnalysis => ({ + analysisOk: false, + allowlistSatisfied: false, + allowlistMatches: [], + segments: [], + segmentSatisfiedBy: [], + }); + const chainParts = isWindowsPlatform(params.platform) ? null : splitCommandChain(params.command); if (!chainParts) { const analysis = analyzeShellCommand({ @@ -265,13 +273,7 @@ export function evaluateShellAllowlist(params: { platform: params.platform, }); if (!analysis.ok) { - return { - analysisOk: false, - allowlistSatisfied: false, - allowlistMatches: [], - segments: [], - segmentSatisfiedBy: [], - }; + return analysisFailure(); } const evaluation = evaluateExecAllowlist({ analysis, @@ -302,13 +304,7 @@ export function evaluateShellAllowlist(params: { platform: params.platform, }); if (!analysis.ok) { - return { - analysisOk: false, - allowlistSatisfied: false, - allowlistMatches: [], - segments: [], - segmentSatisfiedBy: [], - }; + return analysisFailure(); } segments.push(...analysis.segments);