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:
@@ -0,0 +1,63 @@
|
||||
import { isAbsolute } from "node:path";
|
||||
|
||||
import type { PermissionCeiling } from "../domain/permissionPolicy.js";
|
||||
import { ConfigurationError } from "../domain/errors.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { permissionScope } from "./permissions.js";
|
||||
import { parseStringArray } from "./parsers.js";
|
||||
import type { Environment } from "./environment.js";
|
||||
|
||||
export interface ElectronAutomationArrays {
|
||||
readonly electronAutomationExecutableRoots: readonly string[];
|
||||
readonly electronAutomationApplicationRoots: readonly string[];
|
||||
}
|
||||
|
||||
/** Parse the exact filesystem roots admitted for active Electron automation. */
|
||||
export const parseElectronAutomationArrays = (
|
||||
env: Environment,
|
||||
): Result<ElectronAutomationArrays, ConfigurationError> => {
|
||||
const executableRoots = parseAbsoluteRoots(
|
||||
env.REA_ELECTRON_AUTOMATE_EXECUTABLE_ROOTS_JSON,
|
||||
"REA_ELECTRON_AUTOMATE_EXECUTABLE_ROOTS_JSON",
|
||||
);
|
||||
if (!executableRoots.ok) return executableRoots;
|
||||
const applicationRoots = parseAbsoluteRoots(
|
||||
env.REA_ELECTRON_AUTOMATE_APPLICATION_ROOTS_JSON,
|
||||
"REA_ELECTRON_AUTOMATE_APPLICATION_ROOTS_JSON",
|
||||
);
|
||||
if (!applicationRoots.ok) return applicationRoots;
|
||||
return ok({
|
||||
electronAutomationExecutableRoots: executableRoots.value,
|
||||
electronAutomationApplicationRoots: applicationRoots.value,
|
||||
});
|
||||
};
|
||||
|
||||
/** Add the separately permissioned, no-network Electron automation ceiling. */
|
||||
export const appendElectronAutomationCeiling = (
|
||||
ceilings: PermissionCeiling[],
|
||||
env: Environment,
|
||||
arrays: ElectronAutomationArrays,
|
||||
): void => {
|
||||
if (env.REA_ELECTRON_AUTOMATE_ENABLED !== "true") return;
|
||||
ceilings.push(
|
||||
permissionScope(
|
||||
"electron_automate",
|
||||
arrays.electronAutomationApplicationRoots,
|
||||
{
|
||||
executables: arrays.electronAutomationExecutableRoots,
|
||||
network: "external",
|
||||
},
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const parseAbsoluteRoots = (
|
||||
value: string,
|
||||
name: string,
|
||||
): Result<readonly string[], ConfigurationError> => {
|
||||
const parsed = parseStringArray(value, name);
|
||||
if (!parsed.ok) return parsed;
|
||||
return parsed.value.some((root) => !isAbsolute(root))
|
||||
? err(new ConfigurationError(`${name} must encode absolute roots`))
|
||||
: parsed;
|
||||
};
|
||||
@@ -63,6 +63,12 @@ const environmentSchema = z
|
||||
REA_ELECTRON_OBSERVE_ENABLED: z.enum(["true", "false"]).default("false"),
|
||||
REA_ELECTRON_CDP_ENDPOINTS_JSON: z.string().default("[]"),
|
||||
REA_ELECTRON_FILE_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_ELECTRON_AUTOMATE_ENABLED: z.enum(["true", "false"]).default("false"),
|
||||
REA_ELECTRON_AUTOMATE_AUTO_GRANT: z
|
||||
.enum(["true", "false"])
|
||||
.default("false"),
|
||||
REA_ELECTRON_AUTOMATE_EXECUTABLE_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_ELECTRON_AUTOMATE_APPLICATION_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_V8_INSPECTOR_OBSERVE_ENABLED: z
|
||||
.enum(["true", "false"])
|
||||
.default("false"),
|
||||
|
||||
@@ -21,6 +21,11 @@ import {
|
||||
browserEndpointSchema,
|
||||
browserOriginSchema,
|
||||
} from "../domain/browserObservation.js";
|
||||
import {
|
||||
appendElectronAutomationCeiling,
|
||||
parseElectronAutomationArrays,
|
||||
type ElectronAutomationArrays,
|
||||
} from "./electronAutomation.js";
|
||||
|
||||
const DEFAULT_HOPPER_LAUNCHER_PATH =
|
||||
"/Applications/Hopper Disassembler.app/Contents/MacOS/hopper";
|
||||
@@ -29,7 +34,7 @@ const defaultHopperLauncherPath = (): string =>
|
||||
? "/opt/hopper/bin/Hopper"
|
||||
: DEFAULT_HOPPER_LAUNCHER_PATH;
|
||||
|
||||
interface ParsedArrays {
|
||||
interface ParsedArrays extends ElectronAutomationArrays {
|
||||
readonly loaderArgs: readonly string[];
|
||||
readonly executableRoots: readonly string[];
|
||||
readonly workingRoots: readonly string[];
|
||||
@@ -116,6 +121,8 @@ const parseAllArrays = (
|
||||
if (!secretPatterns.ok) return secretPatterns;
|
||||
const observations = parseObservationArrays(env);
|
||||
if (!observations.ok) return observations;
|
||||
const electronAutomation = parseElectronAutomationArrays(env);
|
||||
if (!electronAutomation.ok) return electronAutomation;
|
||||
const javascriptReplayRoots = parseAbsoluteRoots(
|
||||
env.REA_JAVASCRIPT_REPLAY_ROOTS_JSON,
|
||||
"REA_JAVASCRIPT_REPLAY_ROOTS_JSON",
|
||||
@@ -137,6 +144,7 @@ const parseAllArrays = (
|
||||
referenceRoots: referenceRoots.value,
|
||||
secretPatterns: secretPatterns.value,
|
||||
...observations.value,
|
||||
...electronAutomation.value,
|
||||
javascriptReplayRoots: javascriptReplayRoots.value,
|
||||
managedRuntimeRoots: managedRuntimeRoots.value,
|
||||
});
|
||||
@@ -378,6 +386,7 @@ const buildPermissionCeilings = (
|
||||
appendBrowserObservationCeiling(ceilings, env, arrays);
|
||||
appendBrowserScenarioCeiling(ceilings, env, arrays);
|
||||
appendElectronObservationCeiling(ceilings, env, arrays);
|
||||
appendElectronAutomationCeiling(ceilings, env, arrays);
|
||||
appendV8InspectorObservationCeiling(ceilings, env, arrays);
|
||||
appendNativeMountCeiling(ceilings, env);
|
||||
appendJavaScriptReplayCeiling(ceilings, env, arrays);
|
||||
@@ -433,6 +442,11 @@ const buildAppConfig = (
|
||||
electronObservationEnabled: env.REA_ELECTRON_OBSERVE_ENABLED === "true",
|
||||
electronCdpEndpoints: arrays.electronEndpoints,
|
||||
electronFileRoots: arrays.electronFileRoots,
|
||||
electronAutomationPolicy: {
|
||||
enabled: env.REA_ELECTRON_AUTOMATE_ENABLED === "true",
|
||||
executableRoots: arrays.electronAutomationExecutableRoots,
|
||||
applicationRoots: arrays.electronAutomationApplicationRoots,
|
||||
},
|
||||
v8InspectorObservationEnabled:
|
||||
env.REA_V8_INSPECTOR_OBSERVE_ENABLED === "true",
|
||||
v8InspectorEndpoints: arrays.v8InspectorEndpoints,
|
||||
@@ -459,7 +473,9 @@ const buildAppConfig = (
|
||||
(capability !== "process_capture" ||
|
||||
env.REA_PROCESS_CAPTURE_AUTO_GRANT === "true") &&
|
||||
(capability !== "browser_automate" ||
|
||||
env.REA_BROWSER_SCENARIO_AUTO_GRANT === "true"),
|
||||
env.REA_BROWSER_SCENARIO_AUTO_GRANT === "true") &&
|
||||
(capability !== "electron_automate" ||
|
||||
env.REA_ELECTRON_AUTOMATE_AUTO_GRANT === "true"),
|
||||
),
|
||||
),
|
||||
permissionProjectRoot: env.REA_PERMISSION_PROJECT_ROOT,
|
||||
|
||||
@@ -38,6 +38,11 @@ export interface AppConfig {
|
||||
readonly electronObservationEnabled: boolean;
|
||||
readonly electronCdpEndpoints: readonly string[];
|
||||
readonly electronFileRoots: readonly string[];
|
||||
readonly electronAutomationPolicy: {
|
||||
readonly enabled: boolean;
|
||||
readonly executableRoots: readonly string[];
|
||||
readonly applicationRoots: readonly string[];
|
||||
};
|
||||
readonly v8InspectorObservationEnabled: boolean;
|
||||
readonly v8InspectorEndpoints: readonly string[];
|
||||
readonly v8InspectorFileRoots: readonly string[];
|
||||
|
||||
Reference in New Issue
Block a user