refactor(javascript): share static finding source lookup (#16210)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-03 03:48:26 +00:00
1 parent e3fcd07d70
commit c98e199c52
1 file changed
+16 -35
@@ -191,18 +191,23 @@ function* propagateApplicationOwners(
}
}
const findingSourceNode = (
context: JavaScriptArtifactGraphContext,
input: FindingInput<Pick<StaticReference, "module_key" | "module_runtime">>,
): ApplicationNode =>
sourceNodeFor(
context,
input.file.path,
input.value.module_key,
input.value.module_runtime,
) ?? input.asset;
const addReference = (
context: JavaScriptArtifactGraphContext,
input: FindingInput<StaticReference>,
omissions: { selfReferences: number; imports: Map<string, Set<string>> },
): void => {
const source =
sourceNodeFor(
context,
input.file.path,
input.value.module_key,
input.value.module_runtime,
) ?? input.asset;
const source = findingSourceNode(context, input);
const resolved =
input.value.specifier === null ||
input.value.loader_authority === "candidate"
@@ -357,13 +362,7 @@ const addEndpoint = (
context: JavaScriptArtifactGraphContext,
input: FindingInput<StaticEndpoint>,
): void => {
const source =
sourceNodeFor(
context,
input.file.path,
input.value.module_key,
input.value.module_runtime,
) ?? input.asset;
const source = findingSourceNode(context, input);
const key = compactStringIdentityKey(input.value.value);
const candidate = input.value.interpretation === "candidate";
const partial = input.value.resolution === "partial";
@@ -453,13 +452,7 @@ const addStorage = (
const candidate = input.value.interpretation === "candidate";
const limitation =
"The constructor name is only a candidate; an unchanged SQLite module API origin is unproven.";
const source =
sourceNodeFor(
context,
input.file.path,
input.value.module_key,
input.value.module_runtime,
) ?? input.asset;
const source = findingSourceNode(context, input);
const node = context.accumulator.addNode({
kind: "storage",
identity: artifactLocalIdentity(
@@ -571,13 +564,7 @@ const addDiscoveredRole = (
range: input.value.location,
coverage: input.coverage,
});
const source =
sourceNodeFor(
context,
input.file.path,
input.value.module_key,
input.value.module_runtime,
) ?? input.asset;
const source = findingSourceNode(context, input);
addStaticInferenceEdge(context, {
source,
target: role,
@@ -608,13 +595,7 @@ const addCandidateRole = (
): 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 source = findingSourceNode(context, input);
const properties = {
candidate_role: input.value.role,
loader_authority: "candidate",