fix(analysis): preserve producer identity and partial evidence
Reconcile Mach-O UUID observations without hiding malformed or conflicting sources. Require source-map identity digests to be supported by consistent observations. Keep truncated Android manifests as partial raw evidence, validate WABT section framing, and reject missing JEB inventories or error-marked success replies. Consolidate native UUID parsing and simplify capacity and malformed-input fixtures. Focused source and public workflow checks pass, including native arm64e inspection and real WABT framing probes; a successful real JEB GUI project opening remains unverified.
This commit is contained in:
@@ -513,7 +513,84 @@ describe("JavaScript Application Graph: source maps and observations", () => {
|
||||
),
|
||||
).toThrow(/Source-map observation/u);
|
||||
});
|
||||
});
|
||||
|
||||
describe("JavaScript Application Graph: source-map digest consistency", () => {
|
||||
it("rejects source-map observations that contradict a known original digest", () => {
|
||||
const sourceMapNode = (
|
||||
identityDigest: string | null,
|
||||
observedDigest: unknown,
|
||||
contentAvailable?: boolean,
|
||||
) =>
|
||||
createJavaScriptApplicationNode({
|
||||
kind: "source-module",
|
||||
identity: {
|
||||
strategy: "source-map-original",
|
||||
source_root: null,
|
||||
stability: "source-map-exact",
|
||||
source_map_sha256: APPLICATION_GRAPH_DIGESTS.asar,
|
||||
original_source: "src/editor.ts",
|
||||
source_sha256: identityDigest,
|
||||
},
|
||||
observations: [
|
||||
{
|
||||
label: null,
|
||||
source_map_reference: resolveJavaScriptSourceMapReference(
|
||||
"src/editor.ts",
|
||||
null,
|
||||
"dist/app.js.map",
|
||||
),
|
||||
properties: {
|
||||
...(contentAvailable === undefined
|
||||
? {}
|
||||
: { content_available: contentAvailable }),
|
||||
...(observedDigest === undefined
|
||||
? {}
|
||||
: { content_sha256: observedDigest }),
|
||||
},
|
||||
evidence: artifactEvidence(
|
||||
APPLICATION_GRAPH_DIGESTS.asar,
|
||||
"dist/app.js.map",
|
||||
"ast-static-analysis",
|
||||
),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("2".repeat(64), "3".repeat(64))),
|
||||
).toThrow(/Source-map observation/u);
|
||||
expect(() => graphForNode(sourceMapNode(null, "3".repeat(64)))).toThrow(
|
||||
/Source-map observation/u,
|
||||
);
|
||||
expect(() => graphForNode(sourceMapNode(null, 7))).toThrow(
|
||||
/Source-map observation/u,
|
||||
);
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("3".repeat(64), "3".repeat(64))),
|
||||
).not.toThrow();
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("3".repeat(64), "3".repeat(64), false)),
|
||||
).toThrow(/Source-map observation/u);
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("3".repeat(64), null, false)),
|
||||
).toThrow(/Source-map observation/u);
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("3".repeat(64), null, true)),
|
||||
).toThrow(/Source-map observation/u);
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("3".repeat(64), undefined)),
|
||||
).toThrow(/Source-map observation/u);
|
||||
expect(() => graphForNode(sourceMapNode(null, null, true))).toThrow(
|
||||
/Source-map observation/u,
|
||||
);
|
||||
expect(() =>
|
||||
graphForNode(sourceMapNode("3".repeat(64), "3".repeat(64), undefined)),
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("JavaScript Application Graph: commitments and schemas", () => {
|
||||
it("rejects unknown fields and stale commitments", () => {
|
||||
const graph = buildSyntheticJavaScriptApplicationGraph();
|
||||
expect(() =>
|
||||
|
||||
@@ -172,7 +172,28 @@ const sourceMapObservationMatchesIdentity = (
|
||||
observation: ApplicationNode["observations"][number],
|
||||
): boolean => {
|
||||
const { evidence, source_map_reference: reference } = observation;
|
||||
const sourceDigests = [
|
||||
observation.properties.content_sha256,
|
||||
// Older graph producers used `source_sha256` for the same source-map fact.
|
||||
observation.properties.source_sha256,
|
||||
];
|
||||
const hasKnownSourceDigest = identity.source_sha256 !== null;
|
||||
const sourceDigestMatches =
|
||||
sourceDigests.every(
|
||||
(digest) =>
|
||||
digest === undefined ||
|
||||
digest === null ||
|
||||
digest === identity.source_sha256,
|
||||
) &&
|
||||
(!hasKnownSourceDigest || sourceDigests.includes(identity.source_sha256));
|
||||
const contentAvailabilityMatches =
|
||||
(observation.properties.content_available !== true ||
|
||||
hasKnownSourceDigest) &&
|
||||
(observation.properties.content_available !== false ||
|
||||
!hasKnownSourceDigest);
|
||||
return (
|
||||
sourceDigestMatches &&
|
||||
contentAvailabilityMatches &&
|
||||
reference !== null &&
|
||||
evidence.state === "observed" &&
|
||||
evidence.artifact.available &&
|
||||
|
||||
@@ -159,7 +159,8 @@ describe("source to bundle digest changes", () => {
|
||||
"dist/main.js.map",
|
||||
),
|
||||
properties: {
|
||||
source_sha256: HASH.unchanged,
|
||||
content_available: true,
|
||||
content_sha256: HASH.unchanged,
|
||||
source: "src/removed.ts",
|
||||
},
|
||||
evidence: artifactEvidence(HASH.artifact, "dist/main.js.map"),
|
||||
|
||||
Reference in New Issue
Block a user