feat(artifacts): let extraction and JavaScript analysis record integrity mismatches
macOS code signing rewrites unpacked native modules after electron-builder records their ASAR integrity, so the declared and observed hashes of those .node files differ in most signed Electron apps. Claude, ChatGPT, Notion, Obsidian, and Tabby all failed inspect_artifact, extract_artifact, and analyze_javascript_application by default. Only inspect_artifact offered integrity_policy, so extraction and JavaScript analysis of these apps was impossible. extract_artifact and analyze_javascript_application now accept the same integrity_policy (default fail). With record-and-continue, extraction writes the observed bytes, and JavaScript analysis reads contradicted files as observed. Contradicted nested archives stay unexpanded. Both results return the recorded integrity_contradictions and a limitation. The mismatch remediation now names this option instead of only advising a fresh copy, which cannot help for a signed installation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0804722cdf
commit
69af884666
@@ -127,7 +127,11 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => {
|
||||
const standardMessage = standardErrorMessage(error._tag);
|
||||
if (standardMessage !== undefined) return standardMessage;
|
||||
if (error instanceof ArtifactOperationError)
|
||||
return artifactMessage(error.reason);
|
||||
return error.reason === "integrity" &&
|
||||
error.artifactDetails !== undefined &&
|
||||
INTEGRITY_POLICY_OPERATIONS.has(error.operation)
|
||||
? "Artifact bytes contradict their declared integrity. If that is expected, such as an unpacked native module signed after packaging, rerun with integrity_policy record-and-continue to keep the mismatch as an untrusted contradiction; otherwise get a fresh copy."
|
||||
: artifactMessage(error.reason);
|
||||
if (error instanceof EvidenceReferenceError)
|
||||
return error.reason === "missing"
|
||||
? `Evidence ${error.evidenceId} is not retained in this session. Supply complete inline Evidence, re-run its producer, or import its bundle before using this reference.`
|
||||
@@ -216,6 +220,15 @@ const START_FAILURE_TAGS: ReadonlySet<AnalysisErrorTag> = new Set([
|
||||
"HopperStartError",
|
||||
]);
|
||||
|
||||
/** Operations whose callers can record integrity mismatches and continue. */
|
||||
const INTEGRITY_POLICY_OPERATIONS: ReadonlySet<
|
||||
ArtifactOperationError["operation"]
|
||||
> = new Set([
|
||||
"inspect_artifact",
|
||||
"extract_artifact",
|
||||
"analyze_javascript_application",
|
||||
]);
|
||||
|
||||
const artifactMessage = (reason: ArtifactOperationError["reason"]): string => {
|
||||
if (reason === "cancelled")
|
||||
return "Artifact operation was cancelled. Start it again when ready.";
|
||||
|
||||
@@ -122,8 +122,13 @@ const artifactOccurrenceSchema = z.object({
|
||||
limitations: z.array(z.string()),
|
||||
});
|
||||
|
||||
/** Behavior when observed bytes contradict declared artifact integrity. */
|
||||
export const artifactIntegrityPolicySchema = z
|
||||
.enum(["fail", "record-and-continue"])
|
||||
.default("fail");
|
||||
|
||||
/** Observed bytes that contradict a container's declared integrity identity. */
|
||||
const integrityContradictionSchema = z.object({
|
||||
export const integrityContradictionSchema = z.object({
|
||||
contradiction_id: contradictionIdSchema,
|
||||
occurrence_id: occurrenceIdSchema,
|
||||
parent_artifact_id: artifactIdSchema,
|
||||
@@ -211,6 +216,7 @@ export const artifactExtractionResultSchema = z.object({
|
||||
residual_paths: z.array(boundedRelativePathSchema),
|
||||
}),
|
||||
provenance: z.array(artifactCommandSchema),
|
||||
integrity_contradictions: z.array(integrityContradictionSchema).default([]),
|
||||
limitations: z.array(z.string()),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
artifactIntegrityPolicySchema,
|
||||
integrityContradictionSchema,
|
||||
} from "./artifactGraph.js";
|
||||
import { javascriptApplicationGraphSchema } from "./javascriptApplicationGraph.js";
|
||||
import { javaScriptSemanticGraphSchema } from "./javascriptSemanticGraph.js";
|
||||
import { digestSchema } from "./../domain/digests.js";
|
||||
@@ -11,6 +15,7 @@ const countSchema = z.number().int().min(0);
|
||||
export const analyzeJavaScriptApplicationInputSchema = z.strictObject({
|
||||
input_path: z.string().min(1),
|
||||
format: z.enum(["auto", "asar", "directory"]).default("auto"),
|
||||
integrity_policy: artifactIntegrityPolicySchema,
|
||||
});
|
||||
|
||||
/** Compact counts for the high-level Electron architecture/security surface. */
|
||||
@@ -62,6 +67,7 @@ export const javascriptApplicationAnalysisResultSchema = z
|
||||
graph: javascriptApplicationGraphSchema,
|
||||
summary: electronBoundarySummarySchema,
|
||||
statistics: reconstructionStatisticsSchema,
|
||||
integrity_contradictions: z.array(integrityContradictionSchema).default([]),
|
||||
limitations: z.array(z.string().min(1)),
|
||||
semantic_graph: javaScriptSemanticGraphSchema,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user