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;
|
||||
};
|
||||
Reference in New Issue
Block a user