fix: retain completed observations when later analysis steps fail
This commit is contained in:
@@ -77,8 +77,14 @@ export abstract class AnalysisError extends Error {
|
||||
readonly userMessage: string | undefined = undefined;
|
||||
readonly userCategory: "cancelled" | undefined = undefined;
|
||||
readonly executionFailure: string | undefined = undefined;
|
||||
readonly partialObservation: AnalysisPartialObservation | undefined;
|
||||
partialObservation: AnalysisPartialObservation | undefined;
|
||||
readonly cleanupReport: ProcessCaptureCleanupReport | undefined = undefined;
|
||||
|
||||
/** Retain a completed observation when a later step fails. */
|
||||
retainPartialObservation(observation: AnalysisPartialObservation): this {
|
||||
this.partialObservation ??= observation;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
import type {
|
||||
PartialProcessCaptureObservation,
|
||||
@@ -90,6 +96,8 @@ import type { ElectronActivePartialObservation } from "./javascript/electronActi
|
||||
import type { JavaScriptRuntimeObservation } from "./javascript/javascriptRuntimeObservation.js";
|
||||
import type { ArtifactInventoryPartialObservation } from "./artifactPartialObservation.js";
|
||||
import type { BrowserScenarioPartialObservation } from "./browserScenarioCapture.js";
|
||||
import type { Evidence } from "./evidence.js";
|
||||
import type { AndroidPartialObservation } from "./android/androidPartialObservation.js";
|
||||
|
||||
/** Provider-neutral evidence collected before a typed analysis failure. */
|
||||
export type AnalysisPartialObservation =
|
||||
@@ -99,4 +107,6 @@ export type AnalysisPartialObservation =
|
||||
| ElectronActivePartialObservation
|
||||
| BrowserScenarioPartialObservation
|
||||
| JavaScriptRuntimeObservation
|
||||
| ArtifactInventoryPartialObservation;
|
||||
| ArtifactInventoryPartialObservation
|
||||
| Evidence
|
||||
| AndroidPartialObservation;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { digestSchema } from "../digests.js";
|
||||
import { jsonObjectSchema, jsonValueSchema } from "../jsonValue.js";
|
||||
import { localPathStringSchema } from "../localPath.js";
|
||||
|
||||
const operationSchema = z.enum([
|
||||
"inspect_android_package",
|
||||
"search_android_classes",
|
||||
"inspect_android_class",
|
||||
"inspect_android_method",
|
||||
"trace_android_references",
|
||||
]);
|
||||
|
||||
/** JSON-safe Android provider facts collected before an analysis failure. */
|
||||
export const androidPartialObservationSchema = z.strictObject({
|
||||
provider_id: z.literal("jadx"),
|
||||
operation: operationSchema,
|
||||
target: z.strictObject({
|
||||
selected_path: localPathStringSchema,
|
||||
path: localPathStringSchema,
|
||||
sha256: digestSchema,
|
||||
format: z.literal("apk"),
|
||||
}),
|
||||
provider_facts: z.strictObject({
|
||||
jar_sha256: digestSchema.nullable(),
|
||||
bridge_sha256: digestSchema.nullable(),
|
||||
bridge_name: z.string().min(1),
|
||||
bridge_version: z.string().min(1),
|
||||
server_name: z.string().nullable(),
|
||||
server_version: z.string().nullable(),
|
||||
engine_version: z.string().min(1).nullable(),
|
||||
}),
|
||||
calls: z.array(
|
||||
z.strictObject({
|
||||
operation: z.string().min(1),
|
||||
input: jsonObjectSchema,
|
||||
response: jsonValueSchema,
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
/** JSON-safe Android provider facts retained when analysis fails. */
|
||||
export type AndroidPartialObservation = z.infer<
|
||||
typeof androidPartialObservationSchema
|
||||
>;
|
||||
Reference in New Issue
Block a user