feat(native): inspect offline ELF layout through pwntools (#1037)
* feat(native): inspect offline ELF layout through pwntools * fix(build): prepare offline ELF verification on clean runners * fix(native): preserve snapshot acquisition cancellation * fix(native): handle sectionless ELF and retain decoder diagnostics * test(native): verify malformed symbol table entry sizes * fix(native): respect inherited limits and unused segment fields * fix(native): preserve packed relocations and decoder launch constraints * fix(native): validate symbol spans and preserve resource failures * fix(native): preserve diagnostic completeness and memory failures * fix(native): guard bridge imports against allocation failures * fix(native): validate relocation symbol and section references * fix(native): retain diagnostics through compounded cleanup failures * fix(native): preserve unresolved relocation section references * fix(native): bound linkage evidence and preserve CPU signal diagnostics * fix(native): preserve file-size resource failure evidence * fix(native): retain opaque linkage names and late cancellation output * test(native): make CPU-limit fixture robust across runners * fix(native): verify resource failure branches before interpreting exits * fix(native): validate declared ELF string references * fix(native): validate section-name table before decoding * fix(native): enforce canonical ELF name-table escapes
This commit is contained in:
@@ -3,6 +3,9 @@ import {
|
||||
AnalysisCapabilityUnavailableError,
|
||||
AnalysisInputError,
|
||||
AnalysisOutputError,
|
||||
AnalysisCancelledError,
|
||||
AnalysisTimeoutError,
|
||||
AnalysisResourceConstraintError,
|
||||
} from "./analysisErrorCore.js";
|
||||
import { ArtifactOperationError } from "./artifactOperationError.js";
|
||||
import { BinaryTargetError } from "./configurationErrors.js";
|
||||
@@ -16,6 +19,87 @@ import {
|
||||
import { ProviderAdapterError } from "./providerAdapterError.js";
|
||||
import { UnknownRegistryError } from "./unknownRegistryError.js";
|
||||
import { projectAnalysisError } from "./analysisErrorProjection.js";
|
||||
import { ProviderSelectionError } from "./providerSelectionError.js";
|
||||
import { analysisErrorProjectionSchema } from "../contracts/errorSchemas.js";
|
||||
|
||||
const retainedOutput = {
|
||||
stdout: "selected output\u0000",
|
||||
stderr: "upstream warning",
|
||||
truncated: true,
|
||||
};
|
||||
|
||||
it.each([
|
||||
["memory", null],
|
||||
["memory", { address_space_bytes: 67108864 }],
|
||||
["cpu", null],
|
||||
["cpu", { cpu_seconds: 1 }],
|
||||
["file-size", null],
|
||||
["file-size", { file_size_bytes: 1024 }],
|
||||
] as const)(
|
||||
"projects reported %s constraints with observed or unknown limits: %j",
|
||||
(resource, limits) => {
|
||||
const projected = projectAnalysisError(
|
||||
new AnalysisResourceConstraintError(
|
||||
"inspect_binary_layout",
|
||||
resource,
|
||||
resource === "memory"
|
||||
? "Memory allocation failed; exact cause unknown."
|
||||
: "Observed SIGXCPU; exact signal cause unknown.",
|
||||
limits,
|
||||
{ capturedOutput: retainedOutput },
|
||||
),
|
||||
);
|
||||
expect(projected).toMatchObject({
|
||||
code: "resource_constraint",
|
||||
category: "resource_constraint",
|
||||
retryable: false,
|
||||
details: {
|
||||
resource,
|
||||
reported_limits: limits,
|
||||
captured_output: retainedOutput,
|
||||
},
|
||||
});
|
||||
expect(projected.remediation.action).toContain(
|
||||
resource === "cpu"
|
||||
? "CPU"
|
||||
: resource === "file-size"
|
||||
? "file-size"
|
||||
: "memory",
|
||||
);
|
||||
expect(projected.remediation.action).not.toContain("doctor");
|
||||
expect(analysisErrorProjectionSchema.safeParse(projected).success).toBe(
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
it.each([
|
||||
new AnalysisInputError("inspect", { capturedOutput: retainedOutput }),
|
||||
new AnalysisOutputError("inspect", "invalid reply", {
|
||||
capturedOutput: retainedOutput,
|
||||
}),
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"provider",
|
||||
"inspect",
|
||||
"unsupported profile",
|
||||
{ capturedOutput: retainedOutput },
|
||||
),
|
||||
new AnalysisCancelledError("inspect", { capturedOutput: retainedOutput }),
|
||||
new AnalysisTimeoutError("inspect", 30, { capturedOutput: retainedOutput }),
|
||||
new ProviderSelectionError({
|
||||
operation: "inspect",
|
||||
reason: "provider_unavailable",
|
||||
requestedProviderId: "provider",
|
||||
candidateIds: [],
|
||||
capturedOutput: retainedOutput,
|
||||
}),
|
||||
])(
|
||||
"retains captured output without changing the typed primary failure: $._tag",
|
||||
(failure) => {
|
||||
expect(projectAnalysisError(failure).details?.captured_output).toEqual(
|
||||
retainedOutput,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
describe("analysis error projection: provider failures", () => {
|
||||
it("projects the primary browser failure alongside incomplete cleanup", () => {
|
||||
|
||||
Reference in New Issue
Block a user