feat(application): add cross-layer graph workflows

This commit is contained in:
N0zoM1z0
2026-07-16 11:29:54 +09:00
committed by N0zoM1z0
parent 87b23482e2
commit 778b995bbf
218 changed files with 6783 additions and 325 deletions
+25
View File
@@ -99,6 +99,7 @@ const SOURCE_PATHS = {
artifactContracts: "dist/contracts/artifactToolContracts.js",
browserContracts: "dist/contracts/browserToolContracts.js",
electronContracts: "dist/contracts/electronToolContracts.js",
applicationContracts: "dist/contracts/applicationToolContracts.js",
supportedClients: "dist/application/SupportedClients.js",
hopperProvider: "dist/hopper/HopperProvider.js",
ghidraProvider: "dist/ghidra/GhidraProvider.js",
@@ -121,6 +122,9 @@ const SOURCE_PATHS = {
webScreenshot: "dist/domain/webScreenshot.js",
javascriptApplicationGraph: "dist/domain/javascriptApplicationGraph.js",
javascriptApplicationAnalysis: "dist/domain/javascriptApplicationAnalysis.js",
javascriptFeatureTrace: "dist/domain/javascriptFeatureTraceSchemas.js",
javascriptVersionComparison:
"dist/domain/javascriptApplicationVersionComparisonSchemas.js",
reconstructionVerification:
"dist/domain/reconstructionVerificationSchemas.js",
residualUnknown: "dist/domain/residualUnknown.js",
@@ -168,6 +172,11 @@ const toolFamilyCatalog = (sources) => {
surface: "electron-provider",
contracts: sources.electronContracts.ELECTRON_TOOL_CONTRACTS,
},
{
id: "application",
surface: "application-workflow",
contracts: sources.applicationContracts.APPLICATION_TOOL_CONTRACTS,
},
{
id: "session",
surface: "session",
@@ -246,6 +255,11 @@ const providerCatalog = (sources) => {
sources.artifactProviders.JAVASCRIPT_RUNTIME_RECONCILIATION_PROVIDER,
contracts: reconciliationContracts,
},
{
identity:
sources.artifactProviders.JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER,
contracts: sources.applicationContracts.APPLICATION_TOOL_CONTRACTS,
},
]
.map(({ identity, contracts }) => ({
id: identity.id,
@@ -298,6 +312,17 @@ const durableSchemaDefinitions = (sources) => [
sources.javascriptApplicationGraph.javascriptApplicationGraphSchema,
["schema_version"],
],
[
"javascript_application_version_comparison",
sources.javascriptVersionComparison
.applicationVersionComparisonResultSchema,
["schema_version"],
],
[
"javascript_feature_trace",
sources.javascriptFeatureTrace.applicationFeatureTraceResultSchema,
["schema_version"],
],
[
"process_capture",
sources.processCapture.processCaptureSchema,
@@ -0,0 +1,134 @@
#!/usr/bin/env node
import { realpath } from "node:fs/promises";
import { parseArgs } from "node:util";
import { analyzeJavaScriptApplication } from "../dist/application/JavaScriptApplicationService.js";
import {
compareApplicationVersionsEvidence,
traceApplicationFeatureEvidence,
} from "../dist/application/JavaScriptApplicationWorkflowService.js";
import { PermissionAuthority } from "../dist/application/PermissionAuthority.js";
import { applicationVersionComparisonResultSchema } from "../dist/domain/javascriptApplicationVersionComparisonSchemas.js";
import { applicationFeatureTraceResultSchema } from "../dist/domain/javascriptFeatureTraceSchemas.js";
import { createPermissionPolicy } from "../dist/domain/permissionPolicy.js";
const options = parseArgs({
options: {
left: { type: "string" },
right: { type: "string" },
"seed-kind": { type: "string", default: "module" },
"seed-value": { type: "string" },
"source-map-read-approved": { type: "boolean", default: false },
},
strict: true,
allowPositionals: false,
}).values;
if (options.left === undefined || options.right === undefined)
throw new Error(
"--left and --right must name operator-provided app/ASAR paths",
);
const [leftPath, rightPath] = await Promise.all([
realpath(options.left),
realpath(options.right),
]);
if (leftPath === rightPath)
throw new Error("--left and --right must resolve to distinct paths");
const authority = permissionAuthority([leftPath, rightPath]);
const [left, right] = await Promise.all([
analyze(leftPath, authority),
analyze(rightPath, authority),
]);
const comparison = compareApplicationVersionsEvidence({ left, right });
if (!comparison.ok) throw comparison.error;
const comparisonResult = applicationVersionComparisonResultSchema.parse(
comparison.value.normalized_result,
);
const seedValue =
options["seed-value"] ??
left.normalized_result.graph.nodes.find(
({ kind }) => kind === "javascript-module",
)?.observations[0]?.label;
const trace =
seedValue === undefined
? null
: traceApplicationFeatureEvidence({
application: left,
seed: {
kind: options["seed-kind"],
value: seedValue,
match: "exact",
case_sensitive: false,
},
direction: "both",
});
if (trace !== null && !trace.ok) throw trace.error;
const traceResult =
trace === null
? null
: applicationFeatureTraceResultSchema.parse(trace.value.normalized_result);
process.stdout.write(
`${JSON.stringify({
comparison_id: comparisonResult.comparison_id,
evidence_id: comparison.value.evidence_id,
left: comparisonResult.left,
right: comparisonResult.right,
summary: comparisonResult.summary,
matching: comparisonResult.matching,
coverage: comparisonResult.coverage,
trace:
traceResult === null
? null
: {
trace_id: traceResult.trace_id,
evidence_id: trace.value.evidence_id,
seed: traceResult.seed,
summary: traceResult.summary,
coverage: traceResult.coverage,
native_handoffs: traceResult.native_handoffs.map((handoff) => ({
artifact_sha256: handoff.artifact_sha256,
status: handoff.status,
requested_exports: handoff.requested_exports,
evidence_ids: handoff.evidence_ids,
})),
},
verified: true,
})}\n`,
);
async function analyze(path, authority) {
const result = await analyzeJavaScriptApplication(authority, {
input_path: path,
approved: true,
source_map_read_approved: options["source-map-read-approved"],
});
if (!result.ok) throw result.error;
return result.value;
}
function permissionAuthority(roots) {
const scope = {
capability: "investigation_input",
roots,
executables: [],
environment_names: [],
network: "none",
mount: false,
};
return new PermissionAuthority(
createPermissionPolicy(
[scope],
[
{
...scope,
grant_id: "local-application-workflow-verifier",
lifetime: "session",
operation_identity: null,
expires_at: null,
},
],
),
);
}