mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
* feat(javascript)!: require the runtime parse-failure count and active Electron execution paths The V8 Inspector projection always writes scripts.parse_failed_total and the active Electron service always commits parameters.resolved_paths, so both are now required. Runtime reconciliation reads the admitted execution paths only and no longer falls back to request-spelled paths in parameters, and checks the observed executable path against them on every capture. JavaScriptStaticAnalysis.routes and module_runtime keep their omission, which current producers still make (a checkpoint that cannot retain route facts; no recovered factory runtime); their comments now say so instead of naming historical analyses. BREAKING CHANGE: JavaScript runtime observations without scripts.parse_failed_total, and active Electron Evidence without parameters.resolved_paths, are refused as malformed; recreate the observation. * test(javascript): give the shared Node reconciliation fixture the required parse-failure count * feat(browser)!: require browser observation facts their producers always write (#10991) * feat(browser)!: require browser observation facts their producers always write The source-map fetcher always writes effective_url (string or null), the web bundle analyzer always writes schema_property_names_coverage, and the CDP storage fingerprinter always marks IndexedDB schema fingerprints with projection_version 2. Each is now required. The IndexedDB marker is tied to its scope by a discriminated union and derived from the scope in the producer, so compare_web_captures no longer carries the store-only projection branch. response_identity and the WebMCP consequential hint keep their omission, which current producers still make (a body not fully read; an invalid annotation); the guide no longer attributes it to historical captures. BREAKING CHANGE: source-map items without effective_url, WebMCP declarations without schema_property_names_coverage, and IndexedDB schema fingerprints without projection_version are refused as malformed; recreate the capture. * feat(managed)!: refuse members beside a null signature resolution (#10992) * feat(managed)!: refuse members beside a null signature resolution signature_resolution is null only when member decoding exceeded capacity, and the capacity-recovery producer then examines no members. The managed member inspection schema now enforces that: a null resolution with any field, method, member reference, call edge or field access is malformed. With that rule, every admitted inspection with members attests type-name resolution, so the raw-digest fallback is unreachable and is deleted: comparableSides, hasSignatureResolution, the comparison's signatureResolutionExamined flag and the "does not attest" limitation. The shared workflow example that carried resolved digests beside a null attestation now attests resolution. BREAKING CHANGE: managed member Evidence with a null signature_resolution and any examined member is refused as malformed; recreate the observation. * docs: describe historical Evidence by what the format revision now refuses (#10993) SQLite worker_timeout_ms is required, so the SQLite guide no longer reads a missing value as unknown settings. The IL2CPP, ESP image and process capture guides now say that bundles exported without evidence_format are refused, while a standalone record from an earlier release is still read with the stated omission semantics (records carry no format marker yet). The route inventory guide describes a parent without route_inventory by its meaning rather than by its age. * refactor(javascript): require static analysis coverage from the JavaScript worker (#11001) * refactor(javascript): require static analysis coverage from the JavaScript worker Both JavaScript static producers always write analysis_coverage: the analyzer measures it on every parsed source and the failed-parse result carries an unexamined coverage. The worker schema and the static analysis type therefore require it, the preload-discovery checkpoint copies it unconditionally, and ElectronBoundaryAnalysis reads Electron applicability and examination limits from it alone. The fallback that re-derived Electron use from semantic module links and retained references for analyses without coverage is deleted, as are the graph and builder branches for a missing coverage. Retained Evidence graph observations are unchanged: the analysis view still counts a stored JavaScript observation without analysis_coverage as unmeasured, since standalone records carry no format marker yet. The worker runs from the same build as its parent, so no external caller sees the stricter reply schema. * feat(browser)!: require storage fingerprint, Link context, mapping index and invalid-map identity facts (#11002) * feat(browser)!: require storage fingerprint, Link context, mapping index and invalid-map identity facts Each field is written by its only producer on every capture: - The CDP storage capture always writes content_fingerprints, fingerprint_algorithm and fingerprints_complete, so their schema defaults are removed. - The CDP Link header projection always writes context_url and context_scope, so they are required. - The source-map fetcher writes source_index and declaration_index on every mapping row, so they are required. - The fetcher judges a map invalid only after reading its complete body. A separate invalidSourceMapItem builder now takes the response identity as a required argument, and the schema's invalid member requires response_identity; fetch_failed keeps it optional because those rows can come from a body that was not fully read. The browser and source-location guides no longer describe these fields as optional for older saved captures. BREAKING CHANGE: page inspections without the storage fingerprint fields or Link context fields, source-map mapping rows without their indexes, and invalid source-map items without response_identity are refused as malformed; recreate the capture. * test(browser): keep source-omission coverage on a still-defaulted field and refuse a missing fingerprint algorithm * feat(browser)!: require web-bundle target origin, inspection producer facts, scenario redirect state and exclusion kind (#11014) feat(browser)!: require web-bundle target origin, page inspection producer facts, scenario redirect state and exclusion kind Each field is written by its only producer on every record: - buildCaptureObservation always writes capture.target_origin (the validated origin or null), so analyze_web_bundle Evidence and both web-bundle view results require it; the view's conditional spread is gone. - The CDP page capture always writes accessibility node states, script frame_id (null when unattributed) and worker opener_target_id and parent_frame_id, so their schema defaults are removed. - PlaywrightScenarioNetwork writes redirected_from_transaction_state exactly when the predecessor ID is null, so request events now require it there and still refuse it on linked events. - The reference-source importer writes entry_kind on every exclusion (unknown when the kind was not observed), so it is required. The browser scenario contract and CLI guide no longer describe older captures or exclusions without these fields. BREAKING CHANGE: web-bundle analyses without capture.target_origin, page inspections without these script, accessibility or worker fields, scenario network events with a null predecessor and no redirect state, and reference source graphs whose exclusions lack entry_kind are refused as malformed; recreate the capture or re-import the source.
527 lines
17 KiB
TypeScript
527 lines
17 KiB
TypeScript
import { addElectronIpcBoundaries } from "./ElectronBoundaryGraphIpc.js";
|
|
import { createElectronIpcContext } from "./ElectronBoundaryAnalysis.js";
|
|
import { describe, expect, it } from "vitest";
|
|
import { createHash } from "node:crypto";
|
|
|
|
import type { ArtifactInventorySnapshot } from "../../domain/artifactInventorySnapshot.js";
|
|
import type { JavaScriptArtifactFile } from "../../domain/javascript/javascriptArtifactFiles.js";
|
|
import {
|
|
analyzeJavaScriptStaticSource,
|
|
analyzeParsedJavaScriptStaticSource,
|
|
} from "../../../tests/fixtures/javascriptStaticAnalysis.js";
|
|
import { parseJavaScriptSource } from "../../domain/javascript/javascriptSourceParser.js";
|
|
import type {
|
|
AnalyzedJavaScriptArtifactFile,
|
|
JavaScriptArtifactAnalysis,
|
|
} from "./JavaScriptArtifactAnalysisTypes.js";
|
|
import { javascriptArtifactAnalysisScopes } from "./JavaScriptArtifactAnalysisTypes.js";
|
|
import { JavaScriptArtifactGraphAccumulator } from "./JavaScriptArtifactGraphAccumulator.js";
|
|
import type { JavaScriptArtifactGraphContext } from "./JavaScriptArtifactGraphContext.js";
|
|
import {
|
|
addJavaScriptArtifactFiles,
|
|
createJavaScriptArtifactRootNode,
|
|
} from "./JavaScriptArtifactGraphStructure.js";
|
|
import { addJavaScriptStaticFindingsSteps } from "./JavaScriptArtifactGraphFindings.js";
|
|
import { applicationContainerIdentity } from "./JavaScriptArtifactGraphContext.js";
|
|
import { JavaScriptJsonDocuments } from "./JavaScriptJsonDocuments.js";
|
|
|
|
const SHA256 = "a".repeat(64);
|
|
const REASON =
|
|
"main.js: Resource constraint during analyze_javascript_application: Owned JavaScript worker exhausted its heap while analyzing main.js during static";
|
|
|
|
/** Preserve the explicit artifact filename when analyzing owned test fixtures. */
|
|
const analyzeOwnedSource = (source: string, path: string) => {
|
|
const parsed = parseJavaScriptSource(source, path);
|
|
if (parsed === null) throw new Error(`Unable to parse ${path}`);
|
|
return analyzeParsedJavaScriptStaticSource(source, parsed);
|
|
};
|
|
|
|
const skippedFile = (): JavaScriptArtifactFile => ({
|
|
path: "main.js",
|
|
container_sha256: SHA256,
|
|
sha256: SHA256,
|
|
bytes: 5000107,
|
|
inventory_artifact_id: `art_${SHA256}`,
|
|
kind: "javascript",
|
|
unpacked: false,
|
|
text: { included: true, value: "const {ipcMain}=require('electron');\n" },
|
|
});
|
|
|
|
const skippedEntry = (
|
|
file: JavaScriptArtifactFile,
|
|
): AnalyzedJavaScriptArtifactFile => ({
|
|
file,
|
|
javascript: null,
|
|
semantic: null,
|
|
analysis_failure: {
|
|
scope: javascriptArtifactAnalysisScopes["javascript"],
|
|
status: "interrupted",
|
|
reason: REASON,
|
|
error: { code: "resource_constraint" },
|
|
limits: null,
|
|
},
|
|
});
|
|
|
|
const analysisFor = (
|
|
entries: readonly AnalyzedJavaScriptArtifactFile[],
|
|
): JavaScriptArtifactAnalysis => ({
|
|
jsonDocuments: new JavaScriptJsonDocuments(),
|
|
files: entries,
|
|
packages: [],
|
|
json_modules: [],
|
|
html_scripts: [],
|
|
html_inline_scripts: [],
|
|
source_maps: [],
|
|
visited_ast_nodes: 0,
|
|
findings: 0,
|
|
modules: 0,
|
|
parse_failures: 0,
|
|
limitations: [],
|
|
});
|
|
|
|
const contextFor = (
|
|
file: JavaScriptArtifactFile,
|
|
analysis: JavaScriptArtifactAnalysis,
|
|
): JavaScriptArtifactGraphContext => {
|
|
const accumulator = new JavaScriptArtifactGraphAccumulator();
|
|
const snapshot = {
|
|
manifest: {
|
|
root_artifact_id: `art_${SHA256}`,
|
|
root_sha256: SHA256,
|
|
root_format: "directory",
|
|
manifest_id: `agm_${SHA256}`,
|
|
graph_sha256: SHA256,
|
|
},
|
|
nodes: [{ artifact_id: `art_${SHA256}`, sha256: SHA256, size: 1 }],
|
|
// These fixtures model complete directory traversal; source-analysis gaps
|
|
// remain on the individual files and do not imply missing inventory paths.
|
|
coverage: { scope: "root", status: "complete" },
|
|
} as unknown as ArtifactInventorySnapshot;
|
|
const fileSet = {
|
|
files: [file],
|
|
unavailable_relevant_files: [],
|
|
containers: [],
|
|
text_bytes_read: file.bytes,
|
|
invalid_utf8_files: 0,
|
|
};
|
|
return {
|
|
accumulator,
|
|
snapshot,
|
|
fileSet,
|
|
analysis,
|
|
directoryPaths: new Set<string>(),
|
|
root: createJavaScriptArtifactRootNode(accumulator, snapshot),
|
|
filesByPath: new Map([[file.path, file]]),
|
|
unanalyzedFiles: undefined,
|
|
fileNodes: new Map(),
|
|
assetNodes: new Map(),
|
|
sourceModuleNodes: new Map(),
|
|
chunkNodes: new Map(),
|
|
moduleNodes: new Map(),
|
|
containerNodes: new Map(),
|
|
applicationRootsBySource: new Map(),
|
|
applicationOwnershipUnknownContainers: new Set(),
|
|
applicationModuleGapSources: new Map(),
|
|
applicationPossibleRootsByContainer: new Map(),
|
|
applicationModuleReferencesRetained: new Set(),
|
|
};
|
|
};
|
|
|
|
const fileObservation = (context: JavaScriptArtifactGraphContext) => {
|
|
const node = context.accumulator
|
|
.nodes()
|
|
.find(({ kind }) => kind === "javascript-asset");
|
|
if (node === undefined) throw new Error("Expected a javascript-asset node");
|
|
const observation = node.observations[0];
|
|
if (observation === undefined) throw new Error("Expected a file observation");
|
|
return observation.properties;
|
|
};
|
|
|
|
describe("skipped JavaScript parse reporting", () => {
|
|
it("marks parse_status skipped for a JavaScript file whose worker analysis failed", () => {
|
|
const file = skippedFile();
|
|
const context = contextFor(file, analysisFor([skippedEntry(file)]));
|
|
addJavaScriptArtifactFiles(context);
|
|
expect(fileObservation(context).parse_status).toBe("skipped");
|
|
expect(fileObservation(context).analysis_coverage).toMatchObject({
|
|
syntax: { status: "not-examined", error_count: null },
|
|
semantics: { unknown_findings: null },
|
|
examination: { status: "not-examined" },
|
|
});
|
|
});
|
|
|
|
it("keeps parse_status null for a JavaScript file never attempted", () => {
|
|
const file = skippedFile();
|
|
const entry: AnalyzedJavaScriptArtifactFile = {
|
|
file,
|
|
javascript: null,
|
|
semantic: null,
|
|
};
|
|
const context = contextFor(file, analysisFor([entry]));
|
|
addJavaScriptArtifactFiles(context);
|
|
expect(fileObservation(context).parse_status).toBeNull();
|
|
});
|
|
|
|
it("keeps the parsed status for an analyzed JavaScript file", () => {
|
|
const file = skippedFile();
|
|
const javascript = analyzeJavaScriptStaticSource(
|
|
"const {ipcMain}=require('electron');\n",
|
|
);
|
|
const entry: AnalyzedJavaScriptArtifactFile = {
|
|
file,
|
|
javascript,
|
|
semantic: null,
|
|
};
|
|
const context = contextFor(file, analysisFor([entry]));
|
|
addJavaScriptArtifactFiles(context);
|
|
expect(fileObservation(context).parse_status).toBe(javascript.parse_status);
|
|
expect(fileObservation(context).analysis_coverage).toEqual(
|
|
javascript.analysis_coverage,
|
|
);
|
|
});
|
|
});
|
|
|
|
it("preserves omitted inventory facts on an unavailable artifact", () => {
|
|
const file = skippedFile();
|
|
const base = contextFor(file, analysisFor([]));
|
|
const context: JavaScriptArtifactGraphContext = {
|
|
...base,
|
|
fileSet: {
|
|
...base.fileSet,
|
|
files: [],
|
|
unavailable_relevant_files: [
|
|
{
|
|
path: file.path,
|
|
container_sha256: file.container_sha256,
|
|
sha256: null,
|
|
bytes: null,
|
|
inventory_artifact_id: null,
|
|
},
|
|
],
|
|
},
|
|
};
|
|
addJavaScriptArtifactFiles(context);
|
|
const entry = context.accumulator
|
|
.nodes()
|
|
.find(
|
|
({ identity }) =>
|
|
identity.strategy === "canonical-path" && identity.path === file.path,
|
|
);
|
|
expect(entry?.observations[0]?.properties).toEqual({
|
|
path: file.path,
|
|
entry_sha256: null,
|
|
bytes: null,
|
|
inventory_artifact_id: null,
|
|
content_available: false,
|
|
});
|
|
expect(
|
|
context.accumulator
|
|
.edges()
|
|
.find(({ target_node_id }) => target_node_id === entry?.node_id)
|
|
?.properties,
|
|
).toEqual({ path: file.path, content_available: false });
|
|
});
|
|
|
|
it.each([false, true])(
|
|
"retains possible setter owners independently of proven imports (possible owner: %s)",
|
|
(possibleOwner) => {
|
|
const window: JavaScriptArtifactFile = {
|
|
...skippedFile(),
|
|
path: "b/window.cjs",
|
|
sha256: "b".repeat(64),
|
|
};
|
|
const setter: JavaScriptArtifactFile = {
|
|
...skippedFile(),
|
|
path: "shared/change.cjs",
|
|
sha256: "c".repeat(64),
|
|
};
|
|
const page: JavaScriptArtifactFile = {
|
|
...skippedFile(),
|
|
path: "b/index.html",
|
|
sha256: "d".repeat(64),
|
|
kind: "html",
|
|
};
|
|
const analysis = analysisFor([
|
|
{
|
|
file: setter,
|
|
javascript: analyzeOwnedSource(
|
|
'const { app } = require("electron"); app.setAppPath("/changed");',
|
|
setter.path,
|
|
),
|
|
semantic: null,
|
|
},
|
|
{
|
|
file: window,
|
|
javascript: analyzeOwnedSource(
|
|
'const { BrowserWindow } = require("electron"); new BrowserWindow().loadFile("index.html");',
|
|
window.path,
|
|
),
|
|
semantic: null,
|
|
},
|
|
{ file: page, javascript: null, semantic: null },
|
|
]);
|
|
const base = contextFor(window, analysis);
|
|
const files = [setter, window, page];
|
|
const context: JavaScriptArtifactGraphContext = {
|
|
...base,
|
|
fileSet: { ...base.fileSet, files },
|
|
filesByPath: new Map(files.map((file) => [file.path, file])),
|
|
};
|
|
context.applicationRootsBySource.set(setter.path, new Set(["a"]));
|
|
context.applicationRootsBySource.set(window.path, new Set(["b"]));
|
|
if (possibleOwner)
|
|
context.applicationPossibleRootsByContainer.set(
|
|
applicationContainerIdentity(context.fileSet, setter),
|
|
new Set(["b"]),
|
|
);
|
|
addJavaScriptArtifactFiles(context);
|
|
const steps = addJavaScriptStaticFindingsSteps(context);
|
|
let step = steps.next();
|
|
while (!step.done) step = steps.next();
|
|
const role = context.accumulator
|
|
.nodes()
|
|
.find(({ kind }) => kind === "electron-renderer");
|
|
expect(role?.observations).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
properties: expect.objectContaining({
|
|
resolved_path: possibleOwner ? null : "b/index.html",
|
|
resolution_status: possibleOwner ? "unavailable" : "resolved",
|
|
}),
|
|
}),
|
|
]),
|
|
);
|
|
},
|
|
);
|
|
|
|
it.each([
|
|
"unselected",
|
|
"transitive-unselected",
|
|
"invalid-utf8",
|
|
"worker-failure",
|
|
"parse-failed",
|
|
"opaque",
|
|
"unknown-loader",
|
|
"read-inert",
|
|
"unreferenced",
|
|
"json",
|
|
"missing",
|
|
] as const)(
|
|
"does not prove an unchanged application path across a reachable %s load gap",
|
|
(gap) => {
|
|
const makeFile = (
|
|
path: string,
|
|
kind: JavaScriptArtifactFile["kind"] = "javascript",
|
|
): JavaScriptArtifactFile => ({
|
|
...skippedFile(),
|
|
path,
|
|
sha256: createHash("sha256").update(path).digest("hex"),
|
|
kind,
|
|
});
|
|
const main = makeFile("a/main.cjs");
|
|
const other = makeFile("b/main.cjs");
|
|
const target = makeFile(
|
|
gap === "json" ? "a/change.json" : "a/change.cjs",
|
|
gap === "json" ? "json" : "javascript",
|
|
);
|
|
const page = makeFile("a/index.html", "html");
|
|
const otherPage = makeFile("b/index.html", "html");
|
|
const window =
|
|
'const {BrowserWindow}=require("electron");new BrowserWindow().loadFile("index.html");';
|
|
const statement =
|
|
gap === "unknown-loader"
|
|
? "require(process.env.CHANGE);"
|
|
: gap === "transitive-unselected"
|
|
? 'require("./middle.cjs");'
|
|
: gap === "unreferenced"
|
|
? ""
|
|
: `require("./${gap === "json" ? "change.json" : "change.cjs"}");`;
|
|
const entry: AnalyzedJavaScriptArtifactFile =
|
|
gap === "worker-failure"
|
|
? skippedEntry(target)
|
|
: {
|
|
file:
|
|
gap === "invalid-utf8"
|
|
? {
|
|
...target,
|
|
text: { included: false, reason: "invalid-utf8" },
|
|
}
|
|
: target,
|
|
javascript:
|
|
gap === "read-inert"
|
|
? analyzeJavaScriptStaticSource("module.exports=42;")
|
|
: gap === "parse-failed"
|
|
? {
|
|
...analyzeJavaScriptStaticSource(""),
|
|
parse_status: "failed",
|
|
parse_error_count: 1,
|
|
}
|
|
: null,
|
|
semantic: null,
|
|
};
|
|
const entries: AnalyzedJavaScriptArtifactFile[] = [
|
|
{
|
|
file: main,
|
|
javascript: analyzeOwnedSource(statement + window, main.path),
|
|
semantic: null,
|
|
},
|
|
{
|
|
file: other,
|
|
javascript: analyzeOwnedSource(window, other.path),
|
|
semantic: null,
|
|
},
|
|
...(gap === "transitive-unselected"
|
|
? [
|
|
{
|
|
file: makeFile("a/middle.cjs"),
|
|
javascript: analyzeOwnedSource(
|
|
'require("./change.cjs");',
|
|
"a/middle.cjs",
|
|
),
|
|
semantic: null,
|
|
},
|
|
]
|
|
: []),
|
|
...(gap === "missing" || gap === "opaque" ? [] : [entry]),
|
|
{ file: page, javascript: null, semantic: null },
|
|
{ file: otherPage, javascript: null, semantic: null },
|
|
];
|
|
const analysis = analysisFor(entries);
|
|
const base = contextFor(main, analysis);
|
|
const files = entries.map(({ file }) => file);
|
|
const context: JavaScriptArtifactGraphContext = {
|
|
...base,
|
|
fileSet: { ...base.fileSet, files },
|
|
filesByPath: new Map(files.map((file) => [file.path, file])),
|
|
unanalyzedFiles:
|
|
gap === "opaque"
|
|
? {
|
|
get: (path) => (path === target.path ? target : undefined),
|
|
coverage: base.snapshot.coverage,
|
|
hasDirectory: () => false,
|
|
}
|
|
: undefined,
|
|
applicationModuleReferencesRetained: new Set([
|
|
main.path,
|
|
other.path,
|
|
...(gap === "transitive-unselected" ? ["a/middle.cjs"] : []),
|
|
...(gap === "read-inert" ? [target.path] : []),
|
|
]),
|
|
};
|
|
context.applicationRootsBySource.set(main.path, new Set(["a"]));
|
|
context.applicationRootsBySource.set(other.path, new Set(["b"]));
|
|
addJavaScriptArtifactFiles(context);
|
|
const steps = addJavaScriptStaticFindingsSteps(context);
|
|
while (!steps.next().done) {}
|
|
const roles = context.accumulator
|
|
.nodes()
|
|
.filter(({ kind }) => kind === "electron-renderer");
|
|
expect(roles).toHaveLength(2);
|
|
const changed = !["read-inert", "unreferenced", "json", "missing"].includes(
|
|
gap,
|
|
);
|
|
for (const [path, expected] of [
|
|
[main.path, changed ? null : "a/index.html"],
|
|
// Existing loader ownership also allows an unchecked source to import
|
|
// the other app's module; no process isolation has been established.
|
|
[other.path, changed ? null : "b/index.html"],
|
|
] as const) {
|
|
const role = roles.find(({ observations }) =>
|
|
observations.some(
|
|
({ evidence }) =>
|
|
evidence.location.available &&
|
|
evidence.location.value.kind === "source-range" &&
|
|
evidence.location.value.source === path,
|
|
),
|
|
);
|
|
expect(role?.observations).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
properties: expect.objectContaining({
|
|
resolved_path: expected,
|
|
resolution_status: expected === null ? "unavailable" : "resolved",
|
|
}),
|
|
}),
|
|
]),
|
|
);
|
|
}
|
|
},
|
|
);
|
|
|
|
it("attaches sender validation to the innermost handler after a long minified line", () => {
|
|
const source = `const {ipcMain}=require('electron');/*${"x".repeat(2_000_010)}*/ipcMain.handle('outer', event=>{
|
|
ipcMain.handle('inner', event=>{ if(event.senderFrame.url === 'https://trusted.test') return true; });
|
|
});`;
|
|
const file = {
|
|
...skippedFile(),
|
|
bytes: Buffer.byteLength(source),
|
|
text: { included: true as const, value: source },
|
|
};
|
|
const javascript = analyzeJavaScriptStaticSource(source);
|
|
expect(javascript.electron.sender_validations).toHaveLength(1);
|
|
const analysis = analysisFor([{ file, javascript, semantic: null }]);
|
|
const context = contextFor(file, analysis);
|
|
addJavaScriptArtifactFiles(context);
|
|
addElectronIpcBoundaries(
|
|
context,
|
|
createElectronIpcContext(analysis, () => "app"),
|
|
);
|
|
const handlers = context.accumulator
|
|
.nodes()
|
|
.filter(({ kind }) => kind === "ipc-handler");
|
|
const validated = handlers.filter(({ observations }) =>
|
|
observations.some(
|
|
({ properties }) =>
|
|
properties.fact_kind === "sender-validation-candidate",
|
|
),
|
|
);
|
|
expect(validated).toHaveLength(1);
|
|
expect(
|
|
validated[0]?.observations.some(
|
|
({ properties }) => properties.channel === "inner",
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("projects package parse status from the package observation", () => {
|
|
const file = {
|
|
...skippedFile(),
|
|
path: "package.json",
|
|
kind: "package-json" as const,
|
|
};
|
|
const entry: AnalyzedJavaScriptArtifactFile = {
|
|
file,
|
|
javascript: null,
|
|
semantic: null,
|
|
};
|
|
const analysis = {
|
|
...analysisFor([entry]),
|
|
packages: [
|
|
{
|
|
path: file.path,
|
|
sha256: file.sha256,
|
|
status: "included" as const,
|
|
name: "fixture",
|
|
version: null,
|
|
main: null,
|
|
main_status: "default" as const,
|
|
main_entrypoint: "index.js",
|
|
renderer_declarations: {},
|
|
renderer_entrypoint: null,
|
|
limitation: null,
|
|
},
|
|
],
|
|
};
|
|
const context = contextFor(file, analysis);
|
|
addJavaScriptArtifactFiles(context);
|
|
const observation = context.accumulator
|
|
.nodes()
|
|
.flatMap(({ observations }) => observations)
|
|
.find(({ properties }) => properties.file_kind === "package-json");
|
|
expect(observation?.properties).toMatchObject({
|
|
file_kind: "package-json",
|
|
package_parse_status: "included",
|
|
json_parse_status: null,
|
|
});
|
|
});
|