refactor(infra): dedupe exec allowlist analysis failure

This commit is contained in:
Peter Steinberger
2026-02-15 16:05:49 +00:00
parent 7323953ab0
commit e7f65b4aac

View File

@@ -256,6 +256,14 @@ export function evaluateShellAllowlist(params: {
autoAllowSkills?: boolean; autoAllowSkills?: boolean;
platform?: string | null; platform?: string | null;
}): ExecAllowlistAnalysis { }): ExecAllowlistAnalysis {
const analysisFailure = (): ExecAllowlistAnalysis => ({
analysisOk: false,
allowlistSatisfied: false,
allowlistMatches: [],
segments: [],
segmentSatisfiedBy: [],
});
const chainParts = isWindowsPlatform(params.platform) ? null : splitCommandChain(params.command); const chainParts = isWindowsPlatform(params.platform) ? null : splitCommandChain(params.command);
if (!chainParts) { if (!chainParts) {
const analysis = analyzeShellCommand({ const analysis = analyzeShellCommand({
@@ -265,13 +273,7 @@ export function evaluateShellAllowlist(params: {
platform: params.platform, platform: params.platform,
}); });
if (!analysis.ok) { if (!analysis.ok) {
return { return analysisFailure();
analysisOk: false,
allowlistSatisfied: false,
allowlistMatches: [],
segments: [],
segmentSatisfiedBy: [],
};
} }
const evaluation = evaluateExecAllowlist({ const evaluation = evaluateExecAllowlist({
analysis, analysis,
@@ -302,13 +304,7 @@ export function evaluateShellAllowlist(params: {
platform: params.platform, platform: params.platform,
}); });
if (!analysis.ok) { if (!analysis.ok) {
return { return analysisFailure();
analysisOk: false,
allowlistSatisfied: false,
allowlistMatches: [],
segments: [],
segmentSatisfiedBy: [],
};
} }
segments.push(...analysis.segments); segments.push(...analysis.segments);