fix(electron): bound hook retention and report dropped coverage
This commit is contained in:
@@ -61,7 +61,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
const target = typeof args[0] === "string" ? args[0] : null;
|
||||
recordRuntime("preload", "context-bridge-exposure", "attempted", {
|
||||
target,
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
process_type: processType(),
|
||||
});
|
||||
try {
|
||||
@@ -110,7 +110,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
event === "will-download" ? "blocked" : "observed",
|
||||
{
|
||||
target: identity(args[0], "webContents"),
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
error: event === "will-download",
|
||||
},
|
||||
);
|
||||
@@ -124,7 +124,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
(webContents, permission, callback) => {
|
||||
recordRuntime("permission", "permission-request", "blocked", {
|
||||
target: identity(webContents, "webContents"),
|
||||
argument_shapes: [shape(permission)],
|
||||
argument_shape_values: [permission],
|
||||
error: true,
|
||||
});
|
||||
if (typeof callback === "function") callback(false);
|
||||
@@ -137,7 +137,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
return originalPermissionCheck.call(this, (webContents, permission) => {
|
||||
recordRuntime("permission", "permission-check", "blocked", {
|
||||
target: identity(webContents, "webContents"),
|
||||
argument_shapes: [shape(permission)],
|
||||
argument_shape_values: [permission],
|
||||
error: true,
|
||||
});
|
||||
return false;
|
||||
@@ -148,7 +148,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
session.setCertificateVerifyProc = function blockedCertificate() {
|
||||
return originalCertificate.call(this, (request, callback) => {
|
||||
recordRuntime("permission", "certificate-error", "blocked", {
|
||||
argument_shapes: [shape(request)],
|
||||
argument_shape_values: [request],
|
||||
error: true,
|
||||
});
|
||||
if (typeof callback === "function") callback(-2);
|
||||
@@ -168,14 +168,14 @@ const createElectronActiveBoundaryPatches = ({
|
||||
} catch {
|
||||
recordRuntime("popup-attempt", "window-open-handler", "failed", {
|
||||
target: contentsId,
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
error: true,
|
||||
});
|
||||
return { action: "deny" };
|
||||
}
|
||||
recordRuntime("popup-attempt", "window-open-handler", "blocked", {
|
||||
target: contentsId,
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
error: true,
|
||||
});
|
||||
return { action: "deny" };
|
||||
@@ -223,7 +223,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
method === "relaunch" ? "updater" : "protocol",
|
||||
method,
|
||||
"blocked",
|
||||
{ argument_shapes: args.map((value) => shape(value)), error: true },
|
||||
{ argument_shape_values: args, error: true },
|
||||
);
|
||||
return method === "setAsDefaultProtocolClient" ? false : undefined;
|
||||
};
|
||||
@@ -250,11 +250,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
recordRuntime("native-addon", "dlopen", "attempted", {
|
||||
artifact_path: typeof filename === "string" ? filename : null,
|
||||
artifact_sha256: digest,
|
||||
argument_shapes: [
|
||||
shape(module),
|
||||
shape(filename),
|
||||
...args.map((value) => shape(value)),
|
||||
],
|
||||
argument_shape_value_groups: [[module, filename], args],
|
||||
});
|
||||
try {
|
||||
const result = original.call(this, module, filename, ...args);
|
||||
@@ -280,7 +276,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
if (typeof original !== "function") return;
|
||||
utilityProcess.fork = function patchedFork(...args) {
|
||||
recordRuntime("process-lifecycle", "utility-process-fork", "attempted", {
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
process_type: "main",
|
||||
});
|
||||
const child = original.apply(this, args);
|
||||
@@ -304,7 +300,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
recordRuntime("process-lifecycle", `utility.${event}`, "observed", {
|
||||
target: childId,
|
||||
process_type: "utility",
|
||||
argument_shapes: eventArgs.map((value) => shape(value)),
|
||||
argument_shape_values: eventArgs,
|
||||
});
|
||||
});
|
||||
if (child && typeof child.postMessage === "function") {
|
||||
@@ -344,7 +340,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
if (typeof original !== "function") continue;
|
||||
shell[method] = function blockedShellCall(...args) {
|
||||
recordRuntime("shell-attempt", method, "blocked", {
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
error: true,
|
||||
});
|
||||
return Promise.reject(new Error("External shell effects are blocked"));
|
||||
@@ -359,7 +355,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
if (typeof original !== "function") continue;
|
||||
childProcess[method] = function patchedChildProcess(...args) {
|
||||
recordRuntime("process-lifecycle", `child.${method}`, "attempted", {
|
||||
argument_shapes: args.map((value) => shape(value)),
|
||||
argument_shape_values: args,
|
||||
});
|
||||
const child = original.apply(this, args);
|
||||
const childId = identity(child, "child");
|
||||
@@ -369,7 +365,7 @@ const createElectronActiveBoundaryPatches = ({
|
||||
patchEmitter(child, (event, eventArgs) =>
|
||||
recordRuntime("process-lifecycle", `child.${event}`, "observed", {
|
||||
target: childId,
|
||||
argument_shapes: eventArgs.map((value) => shape(value)),
|
||||
argument_shape_values: eventArgs,
|
||||
}),
|
||||
);
|
||||
return child;
|
||||
|
||||
Reference in New Issue
Block a user