refactor: finish lint cleanup
This commit is contained in:
@@ -4,7 +4,11 @@ import {
|
||||
functionComparisonResultSchema,
|
||||
type FunctionComparisonResult,
|
||||
} from "./functionComparisonSchemas.js";
|
||||
import { overallStatus, summarize, canonicalJson } from "./functionComparisonResults.js";
|
||||
import {
|
||||
overallStatus,
|
||||
summarize,
|
||||
canonicalJson,
|
||||
} from "./functionComparisonResults.js";
|
||||
import { compareDimensions } from "./functionComparisonDimensions.js";
|
||||
|
||||
export {
|
||||
|
||||
@@ -16,7 +16,10 @@ import {
|
||||
sorted,
|
||||
stringAndNameProjection,
|
||||
} from "./functionComparisonNormalization.js";
|
||||
import type { DimensionName, FunctionDimension } from "./functionComparisonSchemas.js";
|
||||
import type {
|
||||
DimensionName,
|
||||
FunctionDimension,
|
||||
} from "./functionComparisonSchemas.js";
|
||||
import {
|
||||
canonicalJson,
|
||||
dimensionResult,
|
||||
|
||||
@@ -89,7 +89,12 @@ const applyTier = (context: TierContext): void => {
|
||||
const leftGroup = leftByKey.get(key) ?? [];
|
||||
const rightGroup = rightByKey.get(key) ?? [];
|
||||
if (rightGroup.length === 0) continue;
|
||||
recordCandidates(leftGroup, rightGroup, context.leftCandidates, context.rightCandidates);
|
||||
recordCandidates(
|
||||
leftGroup,
|
||||
rightGroup,
|
||||
context.leftCandidates,
|
||||
context.rightCandidates,
|
||||
);
|
||||
if (leftGroup.length !== 1 || rightGroup.length !== 1) continue;
|
||||
const leftNode = leftGroup[0];
|
||||
const rightNode = rightGroup[0];
|
||||
|
||||
@@ -50,11 +50,23 @@ export const traverseApplicationFeature = (
|
||||
const depth = depths.get(current) ?? 0;
|
||||
for (const entry of adjacency.get(current) ?? []) {
|
||||
if (depth >= limits.max_depth) {
|
||||
recordOmission({ entry, current, omittedNodes, omittedEdges, frontier });
|
||||
recordOmission({
|
||||
entry,
|
||||
current,
|
||||
omittedNodes,
|
||||
omittedEdges,
|
||||
frontier,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (!visited.has(entry.nextNodeId) && visited.size >= limits.max_nodes) {
|
||||
recordOmission({ entry, current, omittedNodes, omittedEdges, frontier });
|
||||
recordOmission({
|
||||
entry,
|
||||
current,
|
||||
omittedNodes,
|
||||
omittedEdges,
|
||||
frontier,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
|
||||
@@ -17,9 +17,7 @@ import {
|
||||
inspectRoleProperty,
|
||||
} from "./javascriptStaticAnalysisCalls.js";
|
||||
import { inspectBundlerRegistration } from "./javascriptStaticAnalysisBundler.js";
|
||||
import {
|
||||
finalizeLocatedFindings,
|
||||
} from "./javascriptStaticAnalysisFindings.js";
|
||||
import { finalizeLocatedFindings } from "./javascriptStaticAnalysisFindings.js";
|
||||
import {
|
||||
createJavaScriptAnalysisAccumulator,
|
||||
type JavaScriptAnalysisAccumulator as AnalysisAccumulator,
|
||||
|
||||
@@ -42,7 +42,7 @@ export interface ManagedGraphProjectionOmissions {
|
||||
}
|
||||
|
||||
/** Complete application-graph fact coverage. */
|
||||
export const completeManagedGraphCoverage =
|
||||
const completeManagedGraphCoverage =
|
||||
(): ApplicationGraphEvidence["coverage"] => ({
|
||||
status: "complete",
|
||||
truncated: false,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { ParsedManagedGraphInput } from "./managedApplicationGraph.js";
|
||||
|
||||
/** Derive module coverage from the best available managed evidence source. */
|
||||
export const moduleCoverageState = (
|
||||
parsed: ParsedManagedGraphInput,
|
||||
): "complete" | "partial" | "unavailable" =>
|
||||
parsed.artifact !== null && parsed.artifact.result.module !== null
|
||||
? parsed.artifact.result.coverage.state
|
||||
: parsed.members !== null && parsed.members.result.module !== null
|
||||
? parsed.members.result.coverage.state
|
||||
: (parsed.boundaries?.result.coverage.state ?? "complete");
|
||||
@@ -1,5 +1,4 @@
|
||||
import { basename } from "node:path";
|
||||
|
||||
import {
|
||||
createJavaScriptApplicationEdge,
|
||||
createJavaScriptApplicationNode,
|
||||
@@ -15,8 +14,11 @@ import {
|
||||
type ManagedMemberInspection,
|
||||
type ManagedNativeBoundaryInspection,
|
||||
} from "./managedArtifact.js";
|
||||
import type { GraphBuildState, ParsedManagedGraphInput } from "./managedApplicationGraph.js";
|
||||
|
||||
import type {
|
||||
GraphBuildState,
|
||||
ParsedManagedGraphInput,
|
||||
} from "./managedApplicationGraph.js";
|
||||
import { moduleCoverageState } from "./managedApplicationGraphNodeCoverage.js";
|
||||
type ManagedMethod = ManagedMemberInspection["methods"]["items"][number];
|
||||
type ManagedField = ManagedMemberInspection["fields"]["items"][number];
|
||||
type ManagedType = ManagedMemberInspection["types"]["items"][number];
|
||||
@@ -204,7 +206,7 @@ export const addMemberNodes = (
|
||||
};
|
||||
|
||||
/** Build a managed type application node. */
|
||||
export const typeNode = (
|
||||
const typeNode = (
|
||||
state: GraphBuildState,
|
||||
type: ManagedType,
|
||||
coverage: ApplicationGraphEvidence["coverage"],
|
||||
@@ -233,7 +235,7 @@ export const typeNode = (
|
||||
});
|
||||
|
||||
/** Build a managed method application node. */
|
||||
export const methodNode = (
|
||||
const methodNode = (
|
||||
state: GraphBuildState,
|
||||
method: ManagedMethod,
|
||||
coverage: ApplicationGraphEvidence["coverage"],
|
||||
@@ -269,7 +271,7 @@ export const methodNode = (
|
||||
});
|
||||
|
||||
/** Build a managed field application node. */
|
||||
export const fieldNode = (
|
||||
const fieldNode = (
|
||||
state: GraphBuildState,
|
||||
field: ManagedField,
|
||||
coverage: ApplicationGraphEvidence["coverage"],
|
||||
@@ -374,7 +376,7 @@ export const addBoundaryNodes = (
|
||||
};
|
||||
|
||||
/** Build a managed P/Invoke import application node. */
|
||||
export const pinvokeNode = (
|
||||
const pinvokeNode = (
|
||||
state: GraphBuildState,
|
||||
pinvoke: PinvokeImport,
|
||||
coverage: ApplicationGraphEvidence["coverage"],
|
||||
@@ -409,7 +411,7 @@ export const pinvokeNode = (
|
||||
});
|
||||
|
||||
/** Build a managed native implementation application node. */
|
||||
export const nativeImplementationNode = (
|
||||
const nativeImplementationNode = (
|
||||
state: GraphBuildState,
|
||||
implementation: NativeImplementation,
|
||||
coverage: ApplicationGraphEvidence["coverage"],
|
||||
@@ -444,7 +446,7 @@ export const nativeImplementationNode = (
|
||||
});
|
||||
|
||||
/** Add a contains relationship edge between two nodes. */
|
||||
export const addContainsEdge = (
|
||||
const addContainsEdge = (
|
||||
state: GraphBuildState,
|
||||
source: ApplicationNode,
|
||||
target: ApplicationNode,
|
||||
@@ -466,7 +468,7 @@ export const addContainsEdge = (
|
||||
};
|
||||
|
||||
/** Build an artifact-local key identity for a managed graph entity. */
|
||||
export const artifactLocalIdentity = (
|
||||
const artifactLocalIdentity = (
|
||||
artifactSha256: string,
|
||||
namespace: string,
|
||||
key: string,
|
||||
@@ -479,10 +481,12 @@ export const artifactLocalIdentity = (
|
||||
});
|
||||
|
||||
/** Build managed static-analysis evidence for a graph observation. */
|
||||
export const managedEvidence = (
|
||||
const managedEvidence = (
|
||||
state: GraphBuildState,
|
||||
operation: string,
|
||||
coverage: ApplicationGraphEvidence["coverage"] = managedSourceCoverage("complete"),
|
||||
coverage: ApplicationGraphEvidence["coverage"] = managedSourceCoverage(
|
||||
"complete",
|
||||
),
|
||||
): ApplicationGraphEvidence => ({
|
||||
authority: "managed-static-analysis",
|
||||
state: "observed",
|
||||
@@ -516,17 +520,7 @@ export const managedEvidence = (
|
||||
});
|
||||
|
||||
/** Sanitize an artifact path into a managed graph location. */
|
||||
export const graphArtifactPath = (path: string): string => {
|
||||
const graphArtifactPath = (path: string): string => {
|
||||
const name = basename(path).replaceAll(/[^A-Za-z0-9._-]/gu, "_");
|
||||
return `managed/${name.length === 0 ? "artifact.pe" : name}`;
|
||||
};
|
||||
|
||||
/** Derive the module coverage state from the best available evidence source. */
|
||||
export const moduleCoverageState = (
|
||||
parsed: ParsedManagedGraphInput,
|
||||
): "complete" | "partial" | "unavailable" =>
|
||||
parsed.artifact !== null && parsed.artifact.result.module !== null
|
||||
? parsed.artifact.result.coverage.state
|
||||
: parsed.members !== null && parsed.members.result.module !== null
|
||||
? parsed.members.result.coverage.state
|
||||
: (parsed.boundaries?.result.coverage.state ?? "complete");
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
} from "./managedMemberComparison.js";
|
||||
import type { ManagedMemberInspection } from "./managedArtifact.js";
|
||||
|
||||
export interface PageAssessment {
|
||||
interface PageAssessment {
|
||||
readonly sourceComplete: boolean;
|
||||
readonly sourceOmittedCount: number;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ const modulePath = (
|
||||
evidence: ReturnType<typeof parseEvidence>,
|
||||
): string | null => evidence.subject?.local_path ?? null;
|
||||
|
||||
export const symbolsForEvidence = (
|
||||
const symbolsForEvidence = (
|
||||
evidence: ReturnType<typeof parseEvidence>,
|
||||
): {
|
||||
readonly supported: boolean;
|
||||
|
||||
@@ -24,12 +24,12 @@ const matchBasisSchema = z.enum([
|
||||
"unsupported-native-evidence",
|
||||
]);
|
||||
|
||||
export const nativeVerificationLimitsSchema = z.strictObject({
|
||||
const nativeVerificationLimitsSchema = z.strictObject({
|
||||
max_native_observations: z.number().int().min(1).max(50).default(20),
|
||||
max_candidates_per_import: z.number().int().min(1).max(100).default(25),
|
||||
});
|
||||
|
||||
export const nativeSymbolSchema = z.strictObject({
|
||||
const nativeSymbolSchema = z.strictObject({
|
||||
evidence_id: evidenceIdSchema,
|
||||
operation: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
|
||||
@@ -26,5 +26,10 @@ export const analyzeCapturedWebBundle = (
|
||||
const accumulator = emptyAccumulator();
|
||||
const sourceScripts = inspection.scripts.items.filter(isIncludedScript);
|
||||
for (const script of sourceScripts) analyzeScript(script, input, accumulator);
|
||||
return buildWebBundleAnalysis(inspection, sourceScripts, sourceMaps, accumulator);
|
||||
return buildWebBundleAnalysis(
|
||||
inspection,
|
||||
sourceScripts,
|
||||
sourceMaps,
|
||||
accumulator,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -334,7 +334,10 @@ const addRouteFrameworkInference = (context: RouteFrameworkContext): void => {
|
||||
value,
|
||||
confidence: "medium",
|
||||
basis: [
|
||||
{ ...basis(context.script, `call:${context.name}`), ...locationFields(context.node) },
|
||||
{
|
||||
...basis(context.script, `call:${context.name}`),
|
||||
...locationFields(context.node),
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
@@ -383,8 +386,9 @@ export const emptyAccumulator = (): AnalysisAccumulator => ({
|
||||
astLimitReached: false,
|
||||
});
|
||||
|
||||
export const isIncludedScript = (script: BrowserScript): script is IncludedScript =>
|
||||
script.source.included;
|
||||
export const isIncludedScript = (
|
||||
script: BrowserScript,
|
||||
): script is IncludedScript => script.source.included;
|
||||
|
||||
const routeCallNames = [
|
||||
"route",
|
||||
|
||||
@@ -3,7 +3,10 @@ import {
|
||||
webBundleAnalysisSchema,
|
||||
type WebBundleAnalysis,
|
||||
} from "./webBundleAnalysis.js";
|
||||
import type { AnalysisAccumulator, IncludedScript } from "./webBundleAnalyzerInspection.js";
|
||||
import type {
|
||||
AnalysisAccumulator,
|
||||
IncludedScript,
|
||||
} from "./webBundleAnalyzerInspection.js";
|
||||
|
||||
export const buildWebBundleAnalysis = (
|
||||
inspection: WebPageInspection,
|
||||
@@ -67,15 +70,13 @@ const buildCaptureObservation = (
|
||||
});
|
||||
|
||||
const sourceArtifact = (script: IncludedScript) => {
|
||||
if (!script.source.included)
|
||||
throw new TypeError("Filtered source changed");
|
||||
if (!script.source.included) throw new TypeError("Filtered source changed");
|
||||
const { text: _text, ...artifact } = script.source.artifact;
|
||||
return { ...artifact, text_available: true };
|
||||
};
|
||||
|
||||
const chunkNode = (script: IncludedScript) => {
|
||||
if (!script.source.included)
|
||||
throw new TypeError("Filtered source changed");
|
||||
if (!script.source.included) throw new TypeError("Filtered source changed");
|
||||
return {
|
||||
script_key: script.script_key,
|
||||
url: script.url,
|
||||
|
||||
Reference in New Issue
Block a user