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:
morlutoandShuaixinHuang authored and GitHub committed 2026-11-09 13:21:24 +08:00
1 parent 78a84d75c0
commit b46f4fcebd
112 files changed
+5156 -797

No files matched your search

@@ -205,7 +205,8 @@ const addReference = (
input.value.module_runtime,
) ?? input.asset;
const resolved =
input.value.specifier === null
input.value.specifier === null ||
input.value.loader_authority === "candidate"
? null
: resolveReference(context, input.file.path, input.value, input.coverage);
if (
@@ -319,11 +320,15 @@ const addReference = (
operation: input.value.operation,
specifier: input.value.specifier,
expression: input.value.expression,
...(input.value.loader_authority === "candidate"
? { loader_authority: "candidate" }
: {}),
resolution_base_path: input.value.resolution_base_path ?? null,
resolution_mode:
input.value.kind === "static-import" ||
input.value.kind === "dynamic-import" ||
input.value.kind === "require"
(input.value.kind === "require" &&
input.value.loader_authority !== "candidate")
? moduleResolutionModeForJavaScriptReference(
input.file.path,
input.value.kind,
@@ -333,7 +338,18 @@ const addReference = (
resolution_status: resolved?.resolution?.resolution_status ?? null,
...artifactPathResolutionProperties(resolved?.resolution),
},
...(resolved === null ? {} : { limitations: resolved.limitations }),
...(input.value.loader_authority === "candidate"
? { confidence: "low" as const }
: {}),
...(resolved === null
? input.value.loader_authority === "candidate"
? {
limitations: [
"The module loader is unknown, so this dependency cannot be resolved against the source file.",
],
}
: {}
: { limitations: resolved.limitations }),
});
};
@@ -354,7 +370,7 @@ const addEndpoint = (
const candidateLimitation =
input.value.kind === "route"
? "Only the property name suggests a route; the enclosing object has no router fields."
: "The unbound method-like argument is only a candidate; its receiver does not establish a network call.";
: "The receiver or loader identity is unproven; this network endpoint is only a candidate.";
const partialLimitation =
"The request target is not an exact literal; the endpoint value retains the unresolved source expression.";
const label = `${input.value.kind} ${candidate ? "endpoint candidate" : "endpoint"}`;
@@ -388,7 +404,10 @@ const addEndpoint = (
operation: "classify-static-endpoint-candidate",
coverage: input.coverage,
confidence: "low",
limitations: [candidateLimitation],
limitations: [
candidateLimitation,
...(partial ? [partialLimitation] : []),
],
})
: astObservationEvidence({
sha256: input.file.sha256,
@@ -416,7 +435,10 @@ const addEndpoint = (
...(candidate
? {
confidence: "low" as const,
limitations: [candidateLimitation],
limitations: [
candidateLimitation,
...(partial ? [partialLimitation] : []),
],
}
: partial
? { limitations: [partialLimitation] }
@@ -496,6 +518,10 @@ const addDiscoveredRole = (
input: FindingInput<StaticRolePath>,
changedRoots: ReadonlySet<string> | null,
): void => {
if (input.value.loader_authority === "candidate") {
addCandidateRole(context, input);
return;
}
const root = applicationRootPath(context, input.file);
const resolved = resolveArtifactPathByContext({
declaredPath: input.value.path,
@@ -575,6 +601,67 @@ const addDiscoveredRole = (
});
};
/** Retain the requested path without asserting that an unknown loader creates an Electron role. */
const addCandidateRole = (
context: JavaScriptArtifactGraphContext,
input: FindingInput<StaticRolePath>,
): void => {
const limitation =
"The Electron loader is unknown, so the renderer role and target ownership remain unproven.";
const source =
sourceNodeFor(
context,
input.file.path,
input.value.module_key,
input.value.module_runtime,
) ?? input.asset;
const properties = {
candidate_role: input.value.role,
loader_authority: "candidate",
declared_path: input.value.path,
resolution_status: "unavailable",
resolved_path: null,
mechanism: input.value.mechanism,
...(input.value.path_base === undefined
? {}
: { path_base: input.value.path_base }),
};
const role = context.accumulator.addNode({
kind: "unknown",
identity: artifactLocalIdentity(
input.file.sha256,
"candidate-electron-role",
JSON.stringify([input.file.path, input.value.path, input.value.location]),
),
observations: [
{
label: input.value.path,
properties,
evidence: staticInferenceEvidence({
sha256: input.file.sha256,
path: input.file.path,
range: input.value.location,
operation: "retain-candidate-electron-role",
coverage: input.coverage,
confidence: "low",
limitations: [limitation],
}),
},
],
});
addStaticInferenceEdge(context, {
source,
target: role,
file: input.file,
range: input.value.location,
coverage: input.coverage,
relation: "loads",
properties,
confidence: "low",
limitations: [limitation],
});
};
const addSourceMapEdge = (
context: JavaScriptArtifactGraphContext,
input: FindingInput<StaticSourceMap>,
@@ -925,6 +1012,9 @@ const unresolvedReferenceNode = (
reference_kind: reference.kind,
specifier: reference.specifier,
expression: reference.expression,
...(reference.loader_authority === "candidate"
? { loader_authority: "candidate" }
: {}),
resolution: "unresolved",
...(resolution === undefined
? {}
@@ -940,6 +1030,9 @@ const unresolvedReferenceNode = (
confidence: "low",
limitations: [
"The static reference could not be resolved within the inventoried artifact.",
...(reference.loader_authority === "candidate"
? ["The module loader is unknown."]
: []),
...(resolution?.limitations ?? []),
],
}),