mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 02:02:45 +00:00
refactor(infra): dedupe exec allowlist analysis failure
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user