fix(javascript): exclude overwritten Electron API identities (#1664)

* fix(javascript): exclude overwritten Electron API identities

* test(javascript): bind Electron in file-base path fixture

* test(electron): bind BrowserWindow in preload override fixtures

* test(mcp): allow cold catalog validation in runtime probe

* test(electron): bind APIs in option reconstruction fixtures
This commit is contained in:
Ysopwnable
2026-10-11 09:25:32 +08:00
committed by GitHub
parent ad41afa2b5
commit 29cc1b8746
13 changed files with 434 additions and 62 deletions
@@ -28,6 +28,7 @@ import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
import { traverseJavaScriptAstSteps } from "./javascriptSemanticTraversal.js";
import {
semanticStaticPropertyKey,
semanticMemberWriteTargets,
unwrapJavaScriptExpression,
} from "./javascriptAstValues.js";
@@ -356,26 +357,14 @@ export function* collectSemanticMemberMutationsSteps(
markEscaped(expression.object, mutation);
};
const markTarget = (node: t.Node, mutation: t.Node): void => {
if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node))
for (const target of semanticMemberWriteTargets(node))
markValue(
node.object,
[semanticStaticPropertyKey(node.property, node.computed)],
target.object,
[semanticStaticPropertyKey(target.property, target.computed)],
new Set(),
"write",
mutation,
);
else if (t.isRestElement(node)) markTarget(node.argument, mutation);
else if (t.isAssignmentPattern(node)) markTarget(node.left, mutation);
else if (t.isArrayPattern(node)) {
for (const element of node.elements)
if (element !== null) markTarget(element, mutation);
} else if (t.isObjectPattern(node)) {
for (const property of node.properties)
markTarget(
t.isRestElement(property) ? property.argument : property.value,
mutation,
);
}
};
yield* traverseJavaScriptAstSteps(program, {
enter: (node, parent) => {