rea-agents 1.7.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -59
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +42 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +11 -29
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +165 -197
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +112 -0
- package/dist/application/ElectronBoundaryGraph.js +9 -0
- package/dist/application/ElectronBoundaryGraphContext.js +62 -0
- package/dist/application/ElectronBoundaryGraphIpc.js +242 -0
- package/dist/application/ElectronBoundaryGraphNative.js +86 -0
- package/dist/application/ElectronBoundaryGraphWindows.js +223 -0
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +58 -50
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationProviders.js +30 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptApplicationEvidence.js +26 -0
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +89 -0
- package/dist/application/JavaScriptApplicationService.js +74 -0
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +29 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +90 -0
- package/dist/application/JavaScriptArtifactAnalysis.js +52 -7
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +82 -17
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphEvidence.js +24 -14
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +4 -1
- package/dist/application/JavaScriptArtifactReconstructionInput.js +2 -83
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayPlanning.js +201 -0
- package/dist/application/JavaScriptReplayService.js +292 -0
- package/dist/application/JavaScriptRuntimeReconciliationEvidence.js +25 -0
- package/dist/application/JavaScriptRuntimeReconciliationService.js +27 -0
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/ManagedApplicationGraphService.js +55 -0
- package/dist/application/ManagedMemberComparisonService.js +122 -0
- package/dist/application/ManagedNativeVerificationService.js +39 -0
- package/dist/application/ManagedReconstructionService.js +58 -0
- package/dist/application/ManagedRuntimeCorrelationService.js +103 -0
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProcessSampling.js +15 -11
- package/dist/application/ProjectPermissionStore.js +49 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/application/runtime.js +2 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +46 -464
- package/dist/browser/CdpElectronInspection.js +106 -162
- package/dist/browser/CdpElectronProvider.js +5 -1
- package/dist/browser/CdpElectronScriptEvents.js +69 -0
- package/dist/browser/CdpElectronScripts.js +94 -0
- package/dist/browser/CdpElectronWorkers.js +56 -0
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -129
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +8 -1
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +13 -383
- package/dist/cliApplicationCommands.js +176 -0
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +17 -0
- package/dist/cliElectronCommands.js +100 -27
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliJsonInput.js +54 -0
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -292
- package/dist/contracts/applicationToolContracts.js +225 -0
- package/dist/contracts/artifactToolContracts.js +5 -9
- package/dist/contracts/browserToolContracts.js +14 -62
- package/dist/contracts/electronToolContracts.js +45 -19
- package/dist/contracts/errorSchemas.js +1 -0
- package/dist/contracts/investigationExamples.js +0 -6
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +46 -0
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +208 -0
- package/dist/contracts/managedToolContracts.js +153 -0
- package/dist/contracts/managedWorkflowExamples.js +346 -0
- package/dist/contracts/managedWorkflowToolContracts.js +203 -0
- package/dist/contracts/nativeToolContracts.js +2 -6
- package/dist/contracts/promptContracts.js +18 -2
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContractExamples.js +10 -25
- package/dist/contracts/toolContracts.js +49 -47
- package/dist/contracts/toolEffects.js +174 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -535
- package/dist/doctorRuntime.js +42 -1
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +37 -19
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -282
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/bundleComparison.js +4 -4
- package/dist/domain/electronObservation.js +13 -0
- package/dist/domain/electronStaticAnalysis.js +9 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +206 -0
- package/dist/domain/electronStaticAnalysisIpc.js +171 -0
- package/dist/domain/electronStaticAnalysisNative.js +164 -0
- package/dist/domain/electronStaticAnalysisTypes.js +1 -0
- package/dist/domain/electronStaticAnalysisValues.js +103 -0
- package/dist/domain/errors.js +32 -448
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/functionComparisonSchemas.js +3 -8
- package/dist/domain/inputIssueProjection.js +52 -0
- package/dist/domain/javascriptApplicationAnalysis.js +155 -0
- package/dist/domain/javascriptApplicationChangeGraph.js +231 -0
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +18 -0
- package/dist/domain/javascriptApplicationGraph.js +2 -1
- package/dist/domain/javascriptApplicationGraphSchemas.js +7 -0
- package/dist/domain/javascriptApplicationVersionComparison.js +116 -0
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +139 -0
- package/dist/domain/javascriptApplicationVersionItems.js +233 -0
- package/dist/domain/javascriptApplicationVersionKeys.js +170 -0
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureSeed.js +140 -0
- package/dist/domain/javascriptFeatureTrace.js +232 -0
- package/dist/domain/javascriptFeatureTraceSchemas.js +136 -0
- package/dist/domain/javascriptFeatureTraversal.js +100 -0
- package/dist/domain/javascriptNativeHandoff.js +85 -0
- package/dist/domain/javascriptReplay.js +361 -0
- package/dist/domain/javascriptRuntimeLoadState.js +106 -0
- package/dist/domain/javascriptRuntimeReconciliation.js +42 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +169 -0
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +247 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +160 -0
- package/dist/domain/javascriptRuntimeReconciliationResult.js +119 -0
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +316 -0
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +245 -0
- package/dist/domain/javascriptRuntimeStaticCandidates.js +193 -0
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +26 -254
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisFindings.js +39 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +81 -2
- package/dist/domain/javascriptStaticAnalysisState.js +6 -0
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +206 -0
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +452 -0
- package/dist/domain/managedMemberComparison.js +211 -0
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +46 -0
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +196 -0
- package/dist/domain/managedRuntimeCorrelation.js +184 -0
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +9 -3
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +339 -0
- package/dist/dotnet/ManagedMemberInspector.js +153 -0
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataHeaps.js +131 -0
- package/dist/dotnet/ManagedMetadataInventory.js +104 -0
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +259 -0
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +143 -0
- package/dist/dotnet/ManagedPeReader.js +188 -0
- package/dist/dotnet/ManagedReaderFailure.js +10 -0
- package/dist/dotnet/ManagedStaticProvider.js +203 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +67 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -132
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +300 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +217 -0
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/LinuxRuntimeClosure.js +46 -0
- package/dist/replay/LinuxSeccompPolicy.js +40 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/replay/ReplayWorkerProtocol.js +55 -0
- package/dist/replay/SystemJavaScriptReplayHost.js +182 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +158 -41
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +13 -0
- package/dist/server/registerArtifactComparisonTool.js +16 -9
- package/dist/server/registerBrowserTools.js +61 -60
- package/dist/server/registerBundleComparisonTool.js +17 -20
- package/dist/server/registerElectronTools.js +39 -12
- package/dist/server/registerEnhancedTools.js +52 -15
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerEvidenceTools.js +5 -1
- package/dist/server/registerFunctionComparisonTool.js +14 -7
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +103 -132
- package/dist/server/registerManagedTools.js +6 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +13 -0
- package/dist/server/registerOfficialTools.js +81 -67
- package/dist/server/registerProcessComparisonTool.js +25 -47
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +9 -8
- package/dist/server/registerSessionTools.js +77 -216
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/sessionEvidence.js +14 -19
- package/dist/server/toolInputValidation.js +77 -0
- package/dist/server/toolRegistrationOptions.js +177 -2
- package/dist/server/toolResult.js +30 -17
- package/package.json +21 -14
- package/scripts/rea.mjs +1 -1
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +75 -6
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import { calleeName, endpointArgument, location, locationFields, objectString, objectValue, propertyName, resolveSpecifier, sanitizeCandidate, stringArgument, } from "./webBundleAnalyzerAst.js";
|
|
4
|
+
export const analyzeScript = (script, input, accumulator) => {
|
|
5
|
+
let file;
|
|
6
|
+
try {
|
|
7
|
+
file = parse(script.source.artifact.text, {
|
|
8
|
+
sourceType: "unambiguous",
|
|
9
|
+
errorRecovery: true,
|
|
10
|
+
plugins: ["jsx", "typescript"],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
accumulator.parseFailures += 1;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
accumulator.parsedScripts += 1;
|
|
18
|
+
detectVendorFingerprints(script, accumulator, input.analysis_limits.max_findings);
|
|
19
|
+
t.traverseFast(file, (node) => {
|
|
20
|
+
accumulator.visitedNodes += 1;
|
|
21
|
+
if (accumulator.visitedNodes > input.analysis_limits.max_ast_nodes) {
|
|
22
|
+
accumulator.astLimitReached = true;
|
|
23
|
+
return t.traverseFast.stop;
|
|
24
|
+
}
|
|
25
|
+
inspectNode(script, node, accumulator, input.analysis_limits.max_findings);
|
|
26
|
+
return undefined;
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const inspectNode = (script, node, accumulator, maximumFindings) => {
|
|
30
|
+
if ((t.isImportDeclaration(node) || t.isExportAllDeclaration(node)) &&
|
|
31
|
+
node.source !== undefined)
|
|
32
|
+
addEdge({
|
|
33
|
+
script,
|
|
34
|
+
specifier: node.source.value,
|
|
35
|
+
kind: "static_import",
|
|
36
|
+
node,
|
|
37
|
+
accumulator,
|
|
38
|
+
maximumFindings,
|
|
39
|
+
});
|
|
40
|
+
else if (t.isExportNamedDeclaration(node) && node.source != null)
|
|
41
|
+
addEdge({
|
|
42
|
+
script,
|
|
43
|
+
specifier: node.source.value,
|
|
44
|
+
kind: "static_import",
|
|
45
|
+
node,
|
|
46
|
+
accumulator,
|
|
47
|
+
maximumFindings,
|
|
48
|
+
});
|
|
49
|
+
else if (t.isImportExpression(node) && t.isStringLiteral(node.source))
|
|
50
|
+
addEdge({
|
|
51
|
+
script,
|
|
52
|
+
specifier: node.source.value,
|
|
53
|
+
kind: "dynamic_import",
|
|
54
|
+
node,
|
|
55
|
+
accumulator,
|
|
56
|
+
maximumFindings,
|
|
57
|
+
});
|
|
58
|
+
if (t.isObjectProperty(node))
|
|
59
|
+
inspectRouteProperty(script, node, accumulator, maximumFindings);
|
|
60
|
+
if (t.isCallExpression(node) || t.isNewExpression(node))
|
|
61
|
+
inspectCall(script, node, accumulator, maximumFindings);
|
|
62
|
+
};
|
|
63
|
+
const inspectCall = (script, node, accumulator, maximumFindings) => {
|
|
64
|
+
const name = calleeName(node.callee);
|
|
65
|
+
const first = stringArgument(node.arguments[0]);
|
|
66
|
+
if ((name === "require" || name.endsWith(".require")) && first !== undefined)
|
|
67
|
+
addEdge({
|
|
68
|
+
script,
|
|
69
|
+
specifier: first,
|
|
70
|
+
kind: "require",
|
|
71
|
+
node,
|
|
72
|
+
accumulator,
|
|
73
|
+
maximumFindings,
|
|
74
|
+
});
|
|
75
|
+
if ((name === "importScripts" || name.endsWith(".importScripts")) &&
|
|
76
|
+
first !== undefined)
|
|
77
|
+
addEdge({
|
|
78
|
+
script,
|
|
79
|
+
specifier: first,
|
|
80
|
+
kind: "worker_import",
|
|
81
|
+
node,
|
|
82
|
+
accumulator,
|
|
83
|
+
maximumFindings,
|
|
84
|
+
});
|
|
85
|
+
if (routeCallNames.some((candidate) => name === candidate || name.endsWith(`.${candidate}`))) {
|
|
86
|
+
if (first !== undefined)
|
|
87
|
+
addFinding({
|
|
88
|
+
collection: accumulator.routes,
|
|
89
|
+
script,
|
|
90
|
+
rawValue: first,
|
|
91
|
+
mechanism: `call:${name}`,
|
|
92
|
+
node,
|
|
93
|
+
accumulator,
|
|
94
|
+
maximumFindings,
|
|
95
|
+
});
|
|
96
|
+
addRouteFrameworkInference({
|
|
97
|
+
script,
|
|
98
|
+
name,
|
|
99
|
+
node,
|
|
100
|
+
accumulator,
|
|
101
|
+
maximumFindings,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const endpoint = endpointArgument(name, node.arguments);
|
|
105
|
+
if (endpoint !== undefined)
|
|
106
|
+
addFinding({
|
|
107
|
+
collection: accumulator.endpoints,
|
|
108
|
+
script,
|
|
109
|
+
rawValue: endpoint,
|
|
110
|
+
mechanism: `call:${name}`,
|
|
111
|
+
node,
|
|
112
|
+
accumulator,
|
|
113
|
+
maximumFindings,
|
|
114
|
+
});
|
|
115
|
+
if (name.endsWith("modelContext.registerTool") ||
|
|
116
|
+
name === "modelContext.registerTool")
|
|
117
|
+
addWebMcpDeclaration(script, node, accumulator, maximumFindings);
|
|
118
|
+
};
|
|
119
|
+
const inspectRouteProperty = (script, node, accumulator, maximumFindings) => {
|
|
120
|
+
const key = propertyName(node.key);
|
|
121
|
+
if ((key === "path" || key === "route") && t.isStringLiteral(node.value))
|
|
122
|
+
addFinding({
|
|
123
|
+
collection: accumulator.routes,
|
|
124
|
+
script,
|
|
125
|
+
rawValue: node.value.value,
|
|
126
|
+
mechanism: `property:${key}`,
|
|
127
|
+
node,
|
|
128
|
+
accumulator,
|
|
129
|
+
maximumFindings,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const addEdge = (context) => {
|
|
133
|
+
const bounded = context.specifier.slice(0, 4_096);
|
|
134
|
+
const key = `edge\0${context.script.script_key}\0${context.kind}\0${bounded}`;
|
|
135
|
+
addBounded(context.accumulator, key, context.maximumFindings, () => context.accumulator.edges.push({
|
|
136
|
+
from_script_key: context.script.script_key,
|
|
137
|
+
kind: context.kind,
|
|
138
|
+
specifier: bounded,
|
|
139
|
+
resolved_url: resolveSpecifier(bounded, context.script.url),
|
|
140
|
+
location: location(context.script.script_key, context.node),
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
const addFinding = (context) => {
|
|
144
|
+
const value = sanitizeCandidate(context.rawValue);
|
|
145
|
+
const key = `finding\0${context.mechanism}\0${context.script.script_key}\0${value}`;
|
|
146
|
+
addBounded(context.accumulator, key, context.maximumFindings, () => context.collection.push({
|
|
147
|
+
value,
|
|
148
|
+
mechanism: context.mechanism,
|
|
149
|
+
location: location(context.script.script_key, context.node),
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
const addWebMcpDeclaration = (script, node, accumulator, maximumFindings) => {
|
|
153
|
+
const declaration = node.arguments[0];
|
|
154
|
+
if (!t.isObjectExpression(declaration))
|
|
155
|
+
return;
|
|
156
|
+
const name = objectString(declaration, "name");
|
|
157
|
+
const description = objectString(declaration, "description");
|
|
158
|
+
const schema = objectValue(declaration, "inputSchema") ??
|
|
159
|
+
objectValue(declaration, "input_schema");
|
|
160
|
+
const declaredProperties = t.isObjectExpression(schema)
|
|
161
|
+
? objectValue(schema, "properties")
|
|
162
|
+
: undefined;
|
|
163
|
+
const propertyObject = t.isObjectExpression(declaredProperties)
|
|
164
|
+
? declaredProperties
|
|
165
|
+
: schema;
|
|
166
|
+
const schemaPropertyNames = t.isObjectExpression(propertyObject)
|
|
167
|
+
? propertyObject.properties.flatMap((property) => t.isObjectProperty(property)
|
|
168
|
+
? [propertyName(property.key)].filter(Boolean)
|
|
169
|
+
: [])
|
|
170
|
+
: [];
|
|
171
|
+
const key = `webmcp\0${script.script_key}\0${name ?? ""}\0${schemaPropertyNames.join("\0")}`;
|
|
172
|
+
addBounded(accumulator, key, maximumFindings, () => accumulator.webMcp.push({
|
|
173
|
+
name: name?.slice(0, 256) ?? null,
|
|
174
|
+
description: description?.slice(0, 2_048) ?? null,
|
|
175
|
+
schema_property_names: [...new Set(schemaPropertyNames)]
|
|
176
|
+
.sort()
|
|
177
|
+
.slice(0, 256),
|
|
178
|
+
trust: "page-declared-untrusted",
|
|
179
|
+
location: location(script.script_key, node),
|
|
180
|
+
}));
|
|
181
|
+
};
|
|
182
|
+
const detectVendorFingerprints = (script, accumulator, maximumFindings) => {
|
|
183
|
+
const text = script.source.artifact.text;
|
|
184
|
+
for (const detector of vendorDetectors) {
|
|
185
|
+
if (!detector.patterns.some((pattern) => text.includes(pattern)))
|
|
186
|
+
continue;
|
|
187
|
+
const key = `vendor\0${script.script_key}\0${detector.value}`;
|
|
188
|
+
addBounded(accumulator, key, maximumFindings, () => accumulator.inferences.push({
|
|
189
|
+
kind: detector.kind,
|
|
190
|
+
value: detector.value,
|
|
191
|
+
confidence: detector.confidence,
|
|
192
|
+
basis: [basis(script, detector.detector)],
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const addRouteFrameworkInference = (context) => {
|
|
197
|
+
const value = context.name.endsWith("useRoutes") ||
|
|
198
|
+
context.name.endsWith("createBrowserRouter")
|
|
199
|
+
? "React Router-compatible route API"
|
|
200
|
+
: "Generic route registration API";
|
|
201
|
+
const key = `route-framework\0${context.script.script_key}\0${value}`;
|
|
202
|
+
addBounded(context.accumulator, key, context.maximumFindings, () => context.accumulator.inferences.push({
|
|
203
|
+
kind: "route_framework",
|
|
204
|
+
value,
|
|
205
|
+
confidence: "medium",
|
|
206
|
+
basis: [
|
|
207
|
+
{
|
|
208
|
+
...basis(context.script, `call:${context.name}`),
|
|
209
|
+
...locationFields(context.node),
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
}));
|
|
213
|
+
};
|
|
214
|
+
const addBounded = (accumulator, key, maximum, add) => {
|
|
215
|
+
if (accumulator.seen.has(key))
|
|
216
|
+
return;
|
|
217
|
+
const findings = accumulator.edges.length +
|
|
218
|
+
accumulator.routes.length +
|
|
219
|
+
accumulator.endpoints.length +
|
|
220
|
+
accumulator.webMcp.length +
|
|
221
|
+
accumulator.inferences.length;
|
|
222
|
+
if (findings >= maximum) {
|
|
223
|
+
accumulator.droppedFindings += 1;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
accumulator.seen.add(key);
|
|
227
|
+
add();
|
|
228
|
+
};
|
|
229
|
+
const basis = (script, detector) => ({
|
|
230
|
+
script_key: script.script_key,
|
|
231
|
+
artifact_sha256: script.source.artifact.sha256,
|
|
232
|
+
line: null,
|
|
233
|
+
column: null,
|
|
234
|
+
detector,
|
|
235
|
+
});
|
|
236
|
+
export const emptyAccumulator = () => ({
|
|
237
|
+
edges: [],
|
|
238
|
+
routes: [],
|
|
239
|
+
endpoints: [],
|
|
240
|
+
webMcp: [],
|
|
241
|
+
inferences: [],
|
|
242
|
+
seen: new Set(),
|
|
243
|
+
visitedNodes: 0,
|
|
244
|
+
parsedScripts: 0,
|
|
245
|
+
parseFailures: 0,
|
|
246
|
+
droppedFindings: 0,
|
|
247
|
+
astLimitReached: false,
|
|
248
|
+
});
|
|
249
|
+
export const isIncludedScript = (script) => script.source.included;
|
|
250
|
+
const routeCallNames = [
|
|
251
|
+
"route",
|
|
252
|
+
"addRoute",
|
|
253
|
+
"useRoutes",
|
|
254
|
+
"createBrowserRouter",
|
|
255
|
+
"createHashRouter",
|
|
256
|
+
];
|
|
257
|
+
const vendorDetectors = [
|
|
258
|
+
{
|
|
259
|
+
value: "webpack",
|
|
260
|
+
detector: "webpack-runtime",
|
|
261
|
+
patterns: ["__webpack_require__"],
|
|
262
|
+
confidence: "high",
|
|
263
|
+
kind: "bundle_runtime",
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
value: "Vite",
|
|
267
|
+
detector: "vite-runtime",
|
|
268
|
+
patterns: ["__vite__", "import.meta.hot"],
|
|
269
|
+
confidence: "medium",
|
|
270
|
+
kind: "bundle_runtime",
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
value: "React",
|
|
274
|
+
detector: "react-runtime",
|
|
275
|
+
patterns: ["__REACT_DEVTOOLS_GLOBAL_HOOK__", "React.createElement"],
|
|
276
|
+
confidence: "medium",
|
|
277
|
+
kind: "vendor_fingerprint",
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
value: "Vue",
|
|
281
|
+
detector: "vue-runtime",
|
|
282
|
+
patterns: ["__VUE__", "createApp("],
|
|
283
|
+
confidence: "medium",
|
|
284
|
+
kind: "vendor_fingerprint",
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
value: "Next.js",
|
|
288
|
+
detector: "next-runtime",
|
|
289
|
+
patterns: ["__NEXT_DATA__", "/_next/"],
|
|
290
|
+
confidence: "high",
|
|
291
|
+
kind: "vendor_fingerprint",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
value: "Angular",
|
|
295
|
+
detector: "angular-runtime",
|
|
296
|
+
patterns: ["ɵɵdefineComponent"],
|
|
297
|
+
confidence: "high",
|
|
298
|
+
kind: "vendor_fingerprint",
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
value: "Svelte",
|
|
302
|
+
detector: "svelte-runtime",
|
|
303
|
+
patterns: ["svelte/internal"],
|
|
304
|
+
confidence: "medium",
|
|
305
|
+
kind: "vendor_fingerprint",
|
|
306
|
+
},
|
|
307
|
+
];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { webBundleAnalysisSchema, } from "./webBundleAnalysis.js";
|
|
2
|
+
export const buildWebBundleAnalysis = (inspection, sourceScripts, sourceMaps, accumulator) => {
|
|
3
|
+
const unavailable = inspection.scripts.items
|
|
4
|
+
.filter((script) => !script.source.included)
|
|
5
|
+
.map(({ script_key }) => script_key);
|
|
6
|
+
const sourceMapIncomplete = sourceMaps.status === "partial" || sourceMaps.status === "unavailable";
|
|
7
|
+
const partial = accumulator.parseFailures > 0 ||
|
|
8
|
+
unavailable.length > 0 ||
|
|
9
|
+
sourceMapIncomplete;
|
|
10
|
+
const truncated = accumulator.astLimitReached ||
|
|
11
|
+
accumulator.droppedFindings > 0 ||
|
|
12
|
+
sourceMaps.status === "truncated";
|
|
13
|
+
return webBundleAnalysisSchema.parse({
|
|
14
|
+
schema_version: 1,
|
|
15
|
+
capture: buildCaptureObservation(inspection, sourceScripts),
|
|
16
|
+
observations: {
|
|
17
|
+
chunks: {
|
|
18
|
+
nodes: sourceScripts.map(chunkNode),
|
|
19
|
+
edges: accumulator.edges,
|
|
20
|
+
},
|
|
21
|
+
routes: accumulator.routes,
|
|
22
|
+
endpoints: accumulator.endpoints,
|
|
23
|
+
webmcp_declarations: accumulator.webMcp,
|
|
24
|
+
source_maps: sourceMaps,
|
|
25
|
+
},
|
|
26
|
+
inferences: accumulator.inferences,
|
|
27
|
+
unknowns: buildUnknowns({
|
|
28
|
+
sourceScripts,
|
|
29
|
+
unavailable,
|
|
30
|
+
parseFailures: accumulator.parseFailures,
|
|
31
|
+
sourceMaps,
|
|
32
|
+
}),
|
|
33
|
+
completeness: buildCompleteness({
|
|
34
|
+
truncated,
|
|
35
|
+
partial,
|
|
36
|
+
parsedScripts: accumulator.parsedScripts,
|
|
37
|
+
parseFailures: accumulator.parseFailures,
|
|
38
|
+
visitedNodes: accumulator.visitedNodes,
|
|
39
|
+
droppedFindings: accumulator.droppedFindings,
|
|
40
|
+
}),
|
|
41
|
+
limitations: bundleLimitations(),
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const buildCaptureObservation = (inspection, sourceScripts) => ({
|
|
45
|
+
target_url: inspection.target.url,
|
|
46
|
+
scripts_observed: inspection.scripts.total,
|
|
47
|
+
scripts_analyzed: sourceScripts.length,
|
|
48
|
+
source_artifacts: sourceScripts.map(sourceArtifact),
|
|
49
|
+
});
|
|
50
|
+
const sourceArtifact = (script) => {
|
|
51
|
+
if (!script.source.included)
|
|
52
|
+
throw new TypeError("Filtered source changed");
|
|
53
|
+
const { text: _text, ...artifact } = script.source.artifact;
|
|
54
|
+
return { ...artifact, text_available: true };
|
|
55
|
+
};
|
|
56
|
+
const chunkNode = (script) => {
|
|
57
|
+
if (!script.source.included)
|
|
58
|
+
throw new TypeError("Filtered source changed");
|
|
59
|
+
return {
|
|
60
|
+
script_key: script.script_key,
|
|
61
|
+
url: script.url,
|
|
62
|
+
artifact_sha256: script.source.artifact.sha256,
|
|
63
|
+
bytes: script.source.artifact.bytes,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const buildUnknowns = (input) => [
|
|
67
|
+
...(input.unavailable.length === 0
|
|
68
|
+
? []
|
|
69
|
+
: [
|
|
70
|
+
{
|
|
71
|
+
dimension: "script_source",
|
|
72
|
+
reason: "Source artifact was not captured within approved limits",
|
|
73
|
+
affected_script_keys: input.unavailable,
|
|
74
|
+
},
|
|
75
|
+
]),
|
|
76
|
+
...(input.parseFailures === 0
|
|
77
|
+
? []
|
|
78
|
+
: [
|
|
79
|
+
{
|
|
80
|
+
dimension: "javascript_ast",
|
|
81
|
+
reason: "One or more source artifacts could not be parsed",
|
|
82
|
+
affected_script_keys: input.sourceScripts.map(({ script_key }) => script_key),
|
|
83
|
+
},
|
|
84
|
+
]),
|
|
85
|
+
...(input.sourceMaps.status === "not_requested" ||
|
|
86
|
+
input.sourceMaps.status === "included"
|
|
87
|
+
? []
|
|
88
|
+
: [
|
|
89
|
+
{
|
|
90
|
+
dimension: "source_maps",
|
|
91
|
+
reason: input.sourceMaps.status === "truncated"
|
|
92
|
+
? "Source-map evidence was truncated by approved limits"
|
|
93
|
+
: "One or more requested source maps were unavailable or incomplete",
|
|
94
|
+
affected_script_keys: [
|
|
95
|
+
...new Set([
|
|
96
|
+
...input.sourceMaps.items
|
|
97
|
+
.filter(({ status }) => status !== "included")
|
|
98
|
+
.map(({ script_key }) => script_key),
|
|
99
|
+
...input.sourceMaps.dropped_script_keys,
|
|
100
|
+
]),
|
|
101
|
+
].sort(),
|
|
102
|
+
},
|
|
103
|
+
]),
|
|
104
|
+
];
|
|
105
|
+
const buildCompleteness = (input) => ({
|
|
106
|
+
status: input.truncated
|
|
107
|
+
? "truncated"
|
|
108
|
+
: input.partial
|
|
109
|
+
? "partial"
|
|
110
|
+
: "complete_within_limits",
|
|
111
|
+
parsed_scripts: input.parsedScripts,
|
|
112
|
+
parse_failures: input.parseFailures,
|
|
113
|
+
visited_ast_nodes: input.visitedNodes,
|
|
114
|
+
dropped_findings: input.droppedFindings,
|
|
115
|
+
});
|
|
116
|
+
const bundleLimitations = () => [
|
|
117
|
+
"Static bundle findings are observations or bounded inferences; REA does not execute captured JavaScript.",
|
|
118
|
+
"String-built routes and endpoints, encrypted configuration, and server-side behavior may remain unknown.",
|
|
119
|
+
"Page-declared WebMCP metadata is untrusted and is never registered or invoked as an REA tool.",
|
|
120
|
+
];
|