mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
fix(process): classify every launcher failure once by errno in the shared launch owner (#11615)
* fix(process): classify every launcher failure once by errno in the shared launch owner * fix(process): keep the launch owner's syscall, cause and facts in RE and pwntools unavailable reports
This commit is contained in:
1 parent
0884836abf
commit
dbb4bc29f0
29 files changed
+712
-289
No files matched your search
@@ -340,6 +340,31 @@ it.each(["ENOEXEC", "EACCES"])(
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps the launch owner's cause and facts on an unavailable selected Python", () => {
|
||||
const launch = Object.assign(new Error("spawn /python EIO"), {
|
||||
code: "EIO",
|
||||
syscall: "spawn /python",
|
||||
path: "/python",
|
||||
});
|
||||
const failure = pwntoolsDecoderFailure(
|
||||
launch,
|
||||
"decoder",
|
||||
"/selected",
|
||||
"/python",
|
||||
);
|
||||
expect(failure.cause).toBe(launch);
|
||||
expect(failure.diagnostics).toMatchObject({
|
||||
boundary: "provider-launch",
|
||||
system_code: "EIO",
|
||||
syscall: "spawn /python",
|
||||
command: "/python",
|
||||
});
|
||||
expect(projectAnalysisError(failure)).toMatchObject({
|
||||
code: "provider_unavailable",
|
||||
message: expect.stringContaining("EIO from spawn /python"),
|
||||
});
|
||||
});
|
||||
|
||||
it("does not read an errno from another syscall as a launch refusal", () => {
|
||||
const unrelated = Object.assign(new Error("open EACCES"), {
|
||||
code: "EACCES",
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
resolvePwntoolsLimits,
|
||||
type PwntoolsProducerLimits,
|
||||
} from "../../domain/native/pwntoolsResourceLimits.js";
|
||||
import type { AnalysisCapturedOutput } from "../../domain/analysisErrorBase.js";
|
||||
import type {
|
||||
AnalysisCapturedOutput,
|
||||
AnalysisErrorOptions,
|
||||
} from "../../domain/analysisErrorBase.js";
|
||||
import type { AnalysisControlLimit } from "../../domain/analysisSettings.js";
|
||||
import type { ProviderProcessSnapshot } from "../../process/ProviderProcess.js";
|
||||
import {
|
||||
@@ -16,6 +19,7 @@ import {
|
||||
import { ProviderAdapterError } from "../../domain/providerAdapterError.js";
|
||||
import { ProviderSelectionError } from "../../domain/providerSelectionError.js";
|
||||
import type { ProviderOutcomeContext } from "../../process/classifyProviderOutcome.js";
|
||||
import { describeLaunchFailure } from "../../process/launchFailure.js";
|
||||
import { OwnedCommandFailure } from "../../process/OwnedCommand.js";
|
||||
import type { ProviderFailureDialect } from "../../providers/classifyProviderFailure.js";
|
||||
import type { PwntoolsFailureEvidence } from "./PwntoolsResourceLimits.js";
|
||||
@@ -209,7 +213,7 @@ export const pwntoolsFailureDialect = (
|
||||
const pwntoolsCommandContext = (
|
||||
state: PwntoolsPhase,
|
||||
limits: PwntoolsProducerLimits,
|
||||
): ProviderOutcomeContext => {
|
||||
): Omit<ProviderOutcomeContext, "providerId"> => {
|
||||
const { executablePath, failureEvidence, context } = state;
|
||||
const limitReport = failureEvidence.limits;
|
||||
const budgetRecovery = pwntoolsBudgetRecovery(limits);
|
||||
@@ -299,15 +303,16 @@ const pwntoolsCommandContext = (
|
||||
PWNTOOLS_LIMITS.cpu_seconds,
|
||||
),
|
||||
},
|
||||
launchUnavailable: (failure, details) =>
|
||||
pwntoolsUnavailable(
|
||||
`Selected Python could not launch (${describeLaunchFailure(failure)}): ${executablePath}. Check the configured executable, its interpreter and host execute access.`,
|
||||
executablePath,
|
||||
failure.code,
|
||||
undefined,
|
||||
context,
|
||||
{ cause: details.cause, diagnostics: details.diagnostics },
|
||||
),
|
||||
dialect: (outcome, details) => {
|
||||
if (outcome.kind === "launch-refused")
|
||||
return pwntoolsUnavailable(
|
||||
`Selected Python could not launch (${outcome.refusal.code}): ${executablePath}. Check the configured executable, its interpreter and host execute access.`,
|
||||
executablePath,
|
||||
outcome.refusal.code,
|
||||
undefined,
|
||||
context,
|
||||
);
|
||||
// A reserved exit means a resource failure only when the bridge's
|
||||
// marker names that resource.
|
||||
const reservedExit =
|
||||
@@ -405,9 +410,15 @@ export const pwntoolsUnavailable = (
|
||||
systemCode?: string,
|
||||
capturedOutput?: AnalysisCapturedOutput,
|
||||
context: PwntoolsFailureContext = DEFAULT_CONTEXT,
|
||||
/** The shared launch owner's cause and parsed facts, for a launch failure. */
|
||||
launch?: Pick<AnalysisErrorOptions, "cause" | "diagnostics">,
|
||||
): ProviderSelectionError =>
|
||||
new ProviderSelectionError({
|
||||
...(capturedOutput === undefined ? {} : { capturedOutput }),
|
||||
...(launch?.cause === undefined ? {} : { cause: launch.cause }),
|
||||
...(launch?.diagnostics === undefined
|
||||
? {}
|
||||
: { diagnostics: launch.diagnostics }),
|
||||
userMessage: reason,
|
||||
operation: context.operation,
|
||||
reason: "provider_unavailable",
|
||||
|
||||
Reference in new issue
Block a user