mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 11:13:21 +00:00
fix(javascript): preserve loader authority for exact suffixes (#9477)
* fix(javascript): require exact loader suffix case * fix(javascript): share exact loader mode across import resolution * test(process): align symlink fixture with filesystem checkpoints * test(javascript): normalize the module resolution oracle path separators * test(frida): assert the CLI spawn Evidence contract * test(mcp): use an unsupported analysis-view parent * test(browser): separate source-location line bounds from parity * fix(javascript): preserve uncertain loader provenance * test(javascript): cover uncertain require resolution * fix(javascript): retain conditional Electron evidence * fix(javascript): preserve timed semantic provenance * fix(javascript): retain conditional builtin effects * test(javascript): distinguish bundled host authority * fix(javascript): preserve nested loader invocation identity * test(javascript): qualify Electron fixture authority * fix(javascript): preserve loader invocation authority * fix(javascript): respect source order for resolver escapes * fix(javascript): check nested loader callable mutations * fix(javascript): retain conditional constructor requests * fix(reference): retain constructor loader relationships * fix(reference): follow nested loader callable paths * refactor(javascript): share callable mutation interpretation * fix(javascript): require exact package loader suffixes * refactor(javascript): unify conditional relation evidence * refactor(javascript): unify conditional node evidence * fix(javascript): retain unknown authority for mixed case sources * fix(javascript): preserve loader uncertainty for dotfiles * fix(reference): classify javascript suffix dotfiles * test(reference): cover suffix dotfiles through cli * fix(javascript): retain equivalent conditional built-in origins * fix(javascript): preserve wrapped resolver operation * fix(javascript): retain nested conditional built-in receivers * test(javascript): declare CommonJS in native addon fixtures * fix(javascript): retain wrapped resolver candidates * style: format merged native command schema * fix(javascript): preserve uncertain loader authority * test(javascript): require candidate preload evidence * test(javascript): cover reference loader member writes --------- Co-authored-by: ShuaixinHuang <1836656514@qq.com>
This commit is contained in:
1 parent
78a84d75c0
commit
b46f4fcebd
112 files changed
+5156
-797
No files matched your search
@@ -62,6 +62,15 @@ const canonicalAmbientPath = (
|
||||
|
||||
type AmbientPath = readonly (string | null)[];
|
||||
|
||||
const ambientEffectCovers = (
|
||||
effect: JavaScriptSemanticAnalysisState["ambientWriteEffects"][number],
|
||||
target: readonly string[],
|
||||
): boolean =>
|
||||
effect.path.length <= target.length &&
|
||||
effect.path.every((key, index) =>
|
||||
semanticPropertyPathKeyMatches(key, target[index]!),
|
||||
);
|
||||
|
||||
const retainedAmbientEffects = new WeakMap<
|
||||
JavaScriptSemanticAnalysisState,
|
||||
Map<t.Node | undefined, Set<string>>
|
||||
@@ -798,8 +807,8 @@ export function* indexJavaScriptAmbientWritesSteps(
|
||||
}
|
||||
}
|
||||
// Settle other ambient effects first. A syntactic resolver call is safe only
|
||||
// if no write or opaque escape can replace the native member anywhere in
|
||||
// this analysis; otherwise retain its receiver escape conservatively.
|
||||
// if no write or opaque escape can replace its native member before this
|
||||
// invocation; ambiguous execution order remains conservative.
|
||||
const resolverReceivers: typeof escapes = [];
|
||||
for (const effect of escapes) {
|
||||
const { node, target } = effect;
|
||||
@@ -821,10 +830,32 @@ export function* indexJavaScriptAmbientWritesSteps(
|
||||
}
|
||||
for (const effect of resolverReceivers) {
|
||||
const { node } = effect;
|
||||
const selected = ["global", "require", "resolve"];
|
||||
const mayAffectResolver = (
|
||||
effects: typeof state.ambientWriteEffects,
|
||||
covered: boolean,
|
||||
): boolean => {
|
||||
if (!covered) return false;
|
||||
const matches = effects.filter((entry) =>
|
||||
ambientEffectCovers(entry, selected),
|
||||
);
|
||||
return (
|
||||
matches.length === 0 ||
|
||||
matches.some(
|
||||
(entry) => semanticEffectTiming(node, entry.node, state) !== "after",
|
||||
)
|
||||
);
|
||||
};
|
||||
if (
|
||||
(t.isCallExpression(node) || t.isOptionalCallExpression(node)) &&
|
||||
!state.ambientWrites.covers(["global", "require", "resolve"]) &&
|
||||
!state.ambientEscapes.covers(["global", "require", "resolve"]) &&
|
||||
!mayAffectResolver(
|
||||
state.ambientWriteEffects,
|
||||
state.ambientWrites.covers(selected),
|
||||
) &&
|
||||
!mayAffectResolver(
|
||||
state.ambientEscapeEffects,
|
||||
state.ambientEscapes.covers(selected),
|
||||
) &&
|
||||
readSemanticRequireLoader(node, state, new Set()) === "commonjs-loader"
|
||||
)
|
||||
continue;
|
||||
@@ -877,14 +908,6 @@ export const createGlobalReferenceReader = (
|
||||
string | null,
|
||||
typeof state.ambientWriteEffects
|
||||
>();
|
||||
const matches = (
|
||||
effect: (typeof state.ambientWriteEffects)[number],
|
||||
target: readonly string[],
|
||||
) =>
|
||||
effect.path.length <= target.length &&
|
||||
effect.path.every((key, index) =>
|
||||
semanticPropertyPathKeyMatches(key, target[index]!),
|
||||
);
|
||||
return (callee) => {
|
||||
const namespace = globalReferenceNamespace(callee, state, path);
|
||||
if (namespace === undefined) return { status: "unrelated" };
|
||||
@@ -901,8 +924,9 @@ export const createGlobalReferenceReader = (
|
||||
if (effects === undefined) {
|
||||
effects = state.ambientWriteEffects.filter(
|
||||
(effect) =>
|
||||
matches(effect, selected) ||
|
||||
(namespace !== null && matches(effect, ["global", namespace])),
|
||||
ambientEffectCovers(effect, selected) ||
|
||||
(namespace !== null &&
|
||||
ambientEffectCovers(effect, ["global", namespace])),
|
||||
);
|
||||
byNamespace.set(namespace, effects);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user