feat(electron): add autonomous Electron runtime analysis (#464)
* feat: add autonomous Electron runtime analysis * feat(electron): add lifecycle and boundary telemetry * feat(electron): capture runtime boundary evidence * fix(electron): package boundary hook helper * feat(electron): report active capture coverage * fix(electron): account for bring-your-own runtime * feat(electron): expand agent-owned runtime scenarios * fix(ghidra): keep fixture credentials out of argv * perf(test): serialize local test and docs workloads * fix(electron): harden active runtime capture * fix(inspector): require exact runtime target authorization * fix(docs): make managed manifest host independent * fix(ci): make generated catalog portable * fix: unblock autonomous command and electron flows * fix(electron): close popup and detached helper gaps
This commit is contained in:
@@ -6,11 +6,14 @@ import { afterEach, expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { createElectronEvidence } from "../../../src/application/ElectronEvidence.js";
|
||||
import { createElectronActiveEvidence } from "../../../src/application/ElectronActiveEvidence.js";
|
||||
import { analyzeJavaScriptApplication } from "../../../src/application/JavaScriptApplicationService.js";
|
||||
import { reconcileJavaScriptRuntime } from "../../../src/domain/javascriptRuntimeReconciliation.js";
|
||||
import { javascriptRuntimeReconciliationResultSchema } from "../../../src/domain/javascriptRuntimeReconciliationSchemas.js";
|
||||
import { electronActiveObservationInputSchema } from "../../../src/domain/electronActiveObservation.js";
|
||||
import { createWebTextArtifact } from "../../../src/domain/webContentArtifact.js";
|
||||
import { permissionAuthorityForRoot } from "../../fixtures/permissionAuthority.js";
|
||||
import { createElectronActiveObservationFixtureResult } from "../../fixtures/electronActiveObservationResult.js";
|
||||
|
||||
const SOURCE = `const worker = new Worker("./worker.js");\nexport const observed = worker;\n`;
|
||||
|
||||
@@ -142,6 +145,87 @@ it("keeps source-map declarations outside primary matching authority", async ()
|
||||
});
|
||||
});
|
||||
|
||||
it("reconciles active Electron as a partial target-only runtime capture", async () => {
|
||||
const fixture = await applicationFixture();
|
||||
temporary.push(fixture);
|
||||
const staticEvidence = await analyzeFixture(fixture);
|
||||
const applicationPath = join(fixture, "main.js");
|
||||
const input = electronActiveObservationInputSchema.parse({
|
||||
schema_version: 1,
|
||||
executable_path: process.execPath,
|
||||
application_path: applicationPath,
|
||||
application_root: fixture,
|
||||
actions: [],
|
||||
approved: true,
|
||||
});
|
||||
const runtimeEvidence = createElectronActiveEvidence(
|
||||
input,
|
||||
createElectronActiveObservationFixtureResult(applicationPath),
|
||||
{
|
||||
id: "rea-playwright-electron-active",
|
||||
name: "REA Playwright active Electron observation provider",
|
||||
version: "1",
|
||||
},
|
||||
);
|
||||
|
||||
const result = reconcileJavaScriptRuntime({
|
||||
static_layers: [{ role: "application", analysis: staticEvidence }],
|
||||
runtime_observations: [runtimeEvidence],
|
||||
});
|
||||
|
||||
expect(result.runtime_captures).toMatchObject([
|
||||
{
|
||||
kind: "electron-active",
|
||||
scripts: 0,
|
||||
frames: 0,
|
||||
workers: 0,
|
||||
scripts_complete_within_scope: false,
|
||||
},
|
||||
]);
|
||||
expect(result.coverage.status).toBe("partial");
|
||||
expect(result.limitations.join(" ")).toMatch(
|
||||
/incomplete|not reported as executed/u,
|
||||
);
|
||||
});
|
||||
|
||||
it("hashes the retained Electron scenario projection, not raw selectors or secrets", async () => {
|
||||
const fixture = await applicationFixture();
|
||||
temporary.push(fixture);
|
||||
const applicationPath = join(fixture, "main.js");
|
||||
const makeInput = (secret: string, selector: string) =>
|
||||
electronActiveObservationInputSchema.parse({
|
||||
schema_version: 1,
|
||||
executable_path: process.execPath,
|
||||
application_path: applicationPath,
|
||||
application_root: fixture,
|
||||
args: ["--token", secret],
|
||||
actions: [{ step_id: "click", kind: "click", selector }],
|
||||
approved: true,
|
||||
});
|
||||
const provider = {
|
||||
id: "rea-playwright-electron-active",
|
||||
name: "REA Playwright active Electron observation provider",
|
||||
version: "1",
|
||||
};
|
||||
const first = createElectronActiveEvidence(
|
||||
makeInput("first-secret", "#first-secret"),
|
||||
createElectronActiveObservationFixtureResult(applicationPath),
|
||||
provider,
|
||||
);
|
||||
const second = createElectronActiveEvidence(
|
||||
makeInput("second-secret", "#second-secret"),
|
||||
createElectronActiveObservationFixtureResult(applicationPath),
|
||||
provider,
|
||||
);
|
||||
|
||||
expect(first.parameters.scenario_sha256).toBe(
|
||||
second.parameters.scenario_sha256,
|
||||
);
|
||||
expect(JSON.stringify(first)).not.toContain("first-secret");
|
||||
expect(JSON.stringify(first)).not.toContain("#first-secret");
|
||||
expect(first.parameters.args).toEqual(["--token", "<redacted>"]);
|
||||
});
|
||||
|
||||
it("imports an operator-provided cache layer through an explicit file mapping", async () => {
|
||||
const application = await applicationFixture();
|
||||
const cache = await createTestTempDirectory("rea-runtime-cache-static-");
|
||||
|
||||
Reference in New Issue
Block a user