rea-agents 6.0.0 → 6.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 +23 -17
- package/bridge/android/ReaJadxBridge.java +14 -5
- package/bridge/ghidra/ReaGhidraBridge.java +173 -47
- package/bridge/hopper_bridge.py +310 -128
- package/bridge/mitmproxy/capture.py +0 -2
- package/bridge/native/rea_lldb_tracer.py +630 -94
- package/bridge/process/ProcessRunTokenReader.swift +39 -5
- package/bridge/pwntools/recorded_crash_impl.py +4 -0
- package/dist/android/JadxConfiguration.js +196 -33
- package/dist/android/JadxMcpTransport.js +4 -0
- package/dist/android/JadxProtocol.js +6 -0
- package/dist/android/JadxProvider.js +19 -2
- package/dist/android/JadxSession.js +23 -4
- package/dist/application/AnalysisContextQueries.js +8 -35
- package/dist/application/AnalysisDocument.js +32 -0
- package/dist/application/AppBundleExecutable.js +67 -21
- package/dist/application/CallPathTracing.js +19 -3
- package/dist/application/CapabilityInventory.js +6 -3
- package/dist/application/ClientConfigurationDocument.js +871 -6
- package/dist/application/ClientRegistrationIdentity.js +26 -5
- package/dist/application/ClientRegistrationStatus.js +29 -14
- package/dist/application/DirectAnalysis.js +27 -37
- package/dist/application/Doctor.js +4 -2
- package/dist/application/DoctorScope.js +25 -13
- package/dist/application/EnhancedLiteralTracing.js +22 -25
- package/dist/application/EnhancedTools.js +13 -11
- package/dist/application/EvidenceBundleFiles.js +23 -11
- package/dist/application/FunctionAnalysisEvidence.js +2 -3
- package/dist/application/InventoryProjectionEvidence.js +4 -3
- package/dist/application/InvestigationProviders.js +3 -2
- package/dist/application/JsonFiles.js +50 -28
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/ReconstructionCoverageService.js +7 -4
- package/dist/application/ReconstructionObligationLedgerService.js +4 -3
- package/dist/application/Setup.js +13 -1
- package/dist/application/SetupClientConfiguration.js +10 -15
- package/dist/application/SetupHost.js +5 -2
- package/dist/application/SetupPlan.js +5 -3
- package/dist/application/SupportedClients.js +34 -1
- package/dist/application/Uninstall.js +4 -3
- package/dist/application/Update.js +18 -3
- package/dist/application/UpdateRuntime.js +46 -25
- package/dist/application/WebModuleTraceService.js +4 -2
- package/dist/application/WebNetworkCaptureService.js +4 -2
- package/dist/application/WebRuntimeService.js +5 -3
- package/dist/application/WebScriptExportService.js +2 -2
- package/dist/application/WebSourceLocationService.js +4 -2
- package/dist/application/WorkflowEvidence.js +82 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +21 -5
- package/dist/application/binary/AnalysisProviderRegistry.js +2 -0
- package/dist/application/binary/AnalysisSnapshotCache.js +3 -6
- package/dist/application/binary/BinarySession.js +95 -68
- package/dist/application/binary/BinarySessionOpen.js +3 -3
- package/dist/application/binary/BinarySessionRecords.js +25 -3
- package/dist/application/binary/BinarySessionStatus.js +17 -1
- package/dist/application/binary/CompositeProvider.js +13 -0
- package/dist/application/binary/LazyAnalysisProvider.js +3 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +4 -2
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +4 -2
- package/dist/application/evm/EvmInterfaceService.js +4 -2
- package/dist/application/investigation/EvidenceLedger.js +21 -7
- package/dist/application/investigation/InvestigationRecords.js +8 -0
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +24 -3
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +22 -15
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +5 -4
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +39 -7
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +6 -3
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +11 -3
- package/dist/application/javascript/JavaScriptModuleRelationships.js +37 -8
- package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +3 -1
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +63 -61
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +23 -1
- package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
- package/dist/application/managed/ManagedMemberComparisonService.js +7 -4
- package/dist/application/managed/ManagedNativeVerificationService.js +4 -3
- package/dist/application/managed/ManagedReconstructionService.js +4 -3
- package/dist/application/process/ProcessCli.js +14 -6
- package/dist/application/process/ProcessEvidence.js +4 -3
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactProvider.js +12 -2
- package/dist/artifacts/MachOSliceArtifactReader.js +98 -14
- package/dist/artifacts/NativeDmgArtifactReader.js +13 -6
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +22 -3
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +36 -22
- package/dist/artifacts/apple/MachoLoadCommandReader.js +92 -31
- package/dist/artifacts/apple/NibArchive.js +81 -14
- package/dist/artifacts/apple/NibViewHierarchy.js +10 -3
- package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +13 -8
- package/dist/artifacts/inventory/scanCanonical.js +11 -14
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
- package/dist/browser/CdpCaptureCompleteness.js +2 -0
- package/dist/browser/CdpCaptureEventHandlers.js +76 -11
- package/dist/browser/CdpCaptureEventTypes.js +5 -1
- package/dist/browser/CdpCaptureEvents.js +25 -0
- package/dist/browser/CdpConnection.js +30 -11
- package/dist/browser/CdpOptionalCommand.js +2 -3
- package/dist/browser/CdpPageCapture.js +23 -1
- package/dist/browser/PlaywrightElectronActiveActions.js +32 -23
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +123 -124
- package/dist/browser/WebSourceMapFetcher.js +426 -72
- package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
- package/dist/browser/history/CaptureFailures.js +37 -1
- package/dist/browser/history/CaptureRelease.js +5 -0
- package/dist/browser/history/HarCaptureAdapter.js +3 -3
- package/dist/browser/history/HarJson.js +3 -2
- package/dist/browser/history/HistoricalCaptureDecoder.js +4 -2
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/applicationCommands.js +2 -3
- package/dist/cli/coreBinaryCommands.js +70 -12
- package/dist/cli/electronCommands.js +7 -6
- package/dist/cli/javascriptApplicationAnalysis.js +7 -3
- package/dist/cli/jsonOutput.js +4 -99
- package/dist/cli/nativeCallCommands.js +2 -3
- package/dist/cli/webRuntimeCommands.js +8 -8
- package/dist/cli.js +2 -1
- package/dist/cliCommandNames.js +0 -1
- package/dist/cliJsonInput.js +9 -4
- package/dist/config/environment.js +4 -0
- package/dist/config/ghidraStartupTimeout.js +17 -0
- package/dist/config/mcpResponseBudget.js +22 -0
- package/dist/config/parseConfig.js +2 -1
- package/dist/contracts/enhancedInputs.js +5 -3
- package/dist/contracts/enhancedToolContracts.js +3 -3
- package/dist/contracts/hopperMemoryContracts.js +2 -5
- package/dist/contracts/javascript/electronToolContracts.js +1 -1
- package/dist/contracts/managed/managedToolContracts.js +2 -4
- package/dist/contracts/native/nativeToolContracts.js +4 -2
- package/dist/contracts/officialToolContracts.js +14 -15
- package/dist/contracts/promptContracts.js +3 -3
- package/dist/contracts/sessionLifecycleInputs.js +3 -7
- package/dist/contracts/sessionStatusContract.js +2 -4
- package/dist/contracts/sessionToolContracts.js +4 -6
- package/dist/contracts/sessionToolSchemas.js +2 -5
- package/dist/contracts/toolContractExamples.js +0 -1
- package/dist/contracts/toolContractHelpers.js +4 -1
- package/dist/contracts/toolEffects.js +0 -1
- package/dist/contracts/toolOutputSchemaGroups.js +28 -27
- package/dist/contracts/toolOutputSchemaPrimitives.js +18 -0
- package/dist/contracts/toolSchemaMetadata.js +69 -10
- package/dist/contracts/webNetworkCaptureToolContracts.js +1 -1
- package/dist/domain/analysisErrorBase.js +8 -3
- package/dist/domain/analysisErrorCore.js +3 -1
- package/dist/domain/analysisErrorPresentation.js +72 -17
- package/dist/domain/analysisErrorProjection.js +106 -27
- package/dist/domain/android/androidAnalysis.js +2 -4
- package/dist/domain/android/androidApplication.js +17 -9
- package/dist/domain/apple/appleApplication.js +41 -14
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dylibResolution.js +120 -9
- package/dist/domain/apple/dylibResolutionFindings.js +9 -7
- package/dist/domain/apple/interfaceBuilderGraph.js +25 -13
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
- package/dist/domain/apple/keyedArchive.js +9 -1
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/artifactIdentity.js +29 -0
- package/dist/domain/artifactInventoryEvidence.js +19 -24
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCompleteness.js +1 -0
- package/dist/domain/browserObservationError.js +24 -5
- package/dist/domain/browserScenarioValues.js +2 -6
- package/dist/domain/bundleComparison.js +3 -2
- package/dist/domain/canonicalJsonDigestSteps.js +133 -0
- package/dist/domain/canonicalOrdering.js +9 -5
- package/dist/domain/changedBehavior.js +6 -6
- package/dist/domain/comparisonSourceEvidence.js +40 -0
- package/dist/domain/configurationErrors.js +1 -1
- package/dist/domain/evidence.js +64 -9
- package/dist/domain/evidenceBundle.js +42 -1
- package/dist/domain/evidenceErrors.js +12 -1
- package/dist/domain/explicitSensitiveFailure.js +17 -1
- package/dist/domain/firmware/firmwareAnalysis.js +6 -7
- package/dist/domain/hopperErrors.js +23 -2
- package/dist/domain/hopperValues.js +51 -8
- package/dist/domain/immutableJson.js +114 -0
- package/dist/domain/inputIssueProjection.js +3 -0
- package/dist/domain/javascript/electronActiveObservation.js +30 -4
- package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
- package/dist/domain/javascript/javascriptApplicationGraph.js +13 -0
- package/dist/domain/javascript/javascriptAstValues.js +20 -0
- package/dist/domain/javascript/javascriptRecovery.js +3 -8
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +97 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +22 -5
- package/dist/domain/javascript/javascriptSemanticGraph.js +13 -0
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +25 -17
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +83 -11
- package/dist/domain/javascript/javascriptSourceParser.js +6 -2
- package/dist/domain/javascript/javascriptStaticAnalysis.js +22 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -3
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +14 -4
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -16
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
- package/dist/domain/jsonSerialization.js +109 -0
- package/dist/domain/jsonValue.js +90 -6
- package/dist/domain/localPath.js +6 -0
- package/dist/domain/managed/managedApplicationGraph.js +10 -10
- package/dist/domain/managed/managedInspectionEvidence.js +16 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
- package/dist/domain/managed/managedNativeVerification.js +3 -9
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeCallObservation.js +33 -11
- package/dist/domain/native/nativeCallPartialObservation.js +33 -0
- package/dist/domain/process/processCapture.js +8 -4
- package/dist/domain/process/processComparison.js +38 -4
- package/dist/domain/process/processScenario.js +11 -10
- package/dist/domain/propertyListKeys.js +1 -1
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +1 -1
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/reconstructionVerification.js +6 -43
- package/dist/domain/reconstructionVerificationSchemas.js +2 -2
- package/dist/domain/staticRuntimeCorrelation.js +6 -43
- package/dist/domain/webBundleAnalysis.js +20 -8
- package/dist/domain/webBundleAnalyzerInspection.js +13 -8
- package/dist/domain/webBundleAnalyzerResult.js +41 -2
- package/dist/domain/webRuntime.js +19 -5
- package/dist/domain/webSourceLocation.js +1 -0
- package/dist/firmware/FirmwareFiles.js +1 -1
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraAnalysisProfile.js +5 -0
- package/dist/ghidra/GhidraClient.js +47 -14
- package/dist/ghidra/GhidraDiagnostics.js +7 -7
- package/dist/ghidra/GhidraFunctionValues.js +10 -7
- package/dist/ghidra/GhidraInstallation.js +18 -21
- package/dist/ghidra/GhidraInventoryValues.js +14 -4
- package/dist/ghidra/GhidraJavaLaunch.js +62 -0
- package/dist/ghidra/GhidraLauncher.js +33 -16
- package/dist/ghidra/GhidraProviderCapabilities.js +14 -2
- package/dist/ghidra/GhidraProviderClient.js +23 -12
- package/dist/ghidra/GhidraSessionError.js +11 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
- package/dist/ghidra/GhidraTransport.js +20 -0
- package/dist/hopper/BridgeLauncher.js +31 -11
- package/dist/hopper/HopperAnalysisProfile.js +62 -4
- package/dist/hopper/HopperCleanup.js +15 -3
- package/dist/hopper/HopperClient.js +222 -14
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +196 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProvider.js +63 -9
- package/dist/hopper/HopperProviderCapabilities.js +19 -1
- package/dist/hopper/HopperRegexSearch.js +137 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +68 -19
- package/dist/hopper/HopperTargetLease.js +3 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
- package/dist/inspector/V8InspectorCaptureProjection.js +8 -3
- package/dist/inspector/V8InspectorProvider.js +47 -11
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
- package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
- package/dist/mcpDoctor.js +62 -2
- package/dist/native/AppleDispatchCoverage.js +47 -6
- package/dist/native/AppleDispatchDecodeFacts.js +6 -0
- package/dist/native/AppleDispatchMetadata.js +6 -3
- package/dist/native/AppleMachoFixups.js +48 -24
- package/dist/native/AppleMachoSelection.js +32 -16
- package/dist/native/AppleObjcCategories.js +6 -2
- package/dist/native/AppleObjcDispatchFacets.js +5 -2
- package/dist/native/AppleObjcProperties.js +2 -1
- package/dist/native/AppleSwiftDispatchFacets.js +27 -21
- package/dist/native/AppleSwiftVtables.js +21 -15
- package/dist/native/CommandRunner.js +81 -84
- package/dist/native/LldbCallTracer.js +365 -102
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +62 -3
- package/dist/native/NativeMacOSProvider.js +98 -17
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/lipo.js +71 -1
- package/dist/native/pwndbg/PwndbgCoreContext.js +25 -5
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +2 -0
- package/dist/process/DarwinProcessRunTokenReader.js +8 -9
- package/dist/process/ExecFileOutput.js +20 -0
- package/dist/process/OwnedCommand.js +7 -2
- package/dist/process/ProcessOwnership.js +203 -53
- package/dist/process/ProcessOwnershipObservation.js +49 -4
- package/dist/process/ProviderProcess.js +38 -7
- package/dist/process/capture/ProcessCaptureError.js +2 -2
- package/dist/process/capture/ProcessCaptureLifecycle.js +100 -34
- package/dist/server/EvidenceMcpServer.js +146 -0
- package/dist/server/createServer.js +15 -8
- package/dist/server/registerAndroidTools.js +2 -4
- package/dist/server/registerApplicationTools/helpers.js +2 -4
- package/dist/server/registerArtifactComparisonTool.js +11 -7
- package/dist/server/registerBinaryDiagnosticsTools.js +2 -4
- package/dist/server/registerBrowserScenarioTool.js +2 -4
- package/dist/server/registerBrowserTools.js +2 -4
- package/dist/server/registerBundleComparisonTool.js +2 -3
- package/dist/server/registerCloseLifecycleTool.js +8 -18
- package/dist/server/registerElectronTools.js +2 -4
- package/dist/server/registerEnhancedTools.js +18 -59
- package/dist/server/registerEvidenceTools.js +2 -4
- package/dist/server/registerEvmTools.js +2 -4
- package/dist/server/registerFirmwareTools.js +2 -4
- package/dist/server/registerFunctionComparisonTool.js +10 -6
- package/dist/server/registerInvestigationTools.js +7 -7
- package/dist/server/registerJavaScriptRecoveryTool.js +2 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +2 -4
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +2 -4
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +2 -4
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +2 -4
- package/dist/server/registerOfficialTools.js +2 -4
- package/dist/server/registerProcessComparisonTool.js +71 -45
- package/dist/server/registerRecordedCrashTools.js +2 -4
- package/dist/server/registerSessionRecordTools.js +5 -6
- package/dist/server/registerSessionStatusTool.js +17 -3
- package/dist/server/registerSessionTools.js +11 -3
- package/dist/server/registerWebModuleTool.js +2 -4
- package/dist/server/registerWebNetworkCaptureTool.js +2 -4
- package/dist/server/registerWebRuntimeTools.js +3 -7
- package/dist/server/registerWebScriptTool.js +2 -4
- package/dist/server/registerWebSourceLocationTool.js +2 -4
- package/dist/server/runDerivedOperation.js +15 -3
- package/dist/server/sessionAvailabilityPolicy.js +0 -1
- package/dist/server/toolRegistrationOptions.js +2 -2
- package/dist/server/toolResult.js +62 -10
- package/dist/server/toolResultEncoding.js +33 -0
- package/install.sh +1 -1
- package/native/windows/build/manifest.json +1 -1
- package/package.json +8 -3
- package/scripts/electron-active-hook-boundaries.cjs +18 -20
- package/scripts/electron-active-hook.cjs +241 -37
- package/skills/reverse-engineer-anything/SKILL.md +11 -3
- package/skills/reverse-engineer-anything/references/javascript-applications.md +8 -1
- package/dist/ghidra/GhidraDefaults.js +0 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
2
|
import { compareCodePoints } from "../../domain/canonicalOrdering.js";
|
|
3
3
|
import { completeApplicationCoverage, partialApplicationCoverage, } from "../../domain/javascript/javascriptApplicationEvidenceSchemas.js";
|
|
4
|
+
import { semanticCoverageResourceLimits } from "../../domain/javascript/javascriptSemanticCoverage.js";
|
|
5
|
+
import { SEMANTIC_EXPRESSION_DEPTH_LIMIT, SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT, SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT, semanticResourceLimitReason, } from "../../domain/javascript/javascriptSemanticResourceLimits.js";
|
|
4
6
|
import { addAstContainsEdge, artifactLocalIdentity, } from "./JavaScriptArtifactGraphContext.js";
|
|
5
7
|
import { astObservationEvidence, staticInferenceEvidence, } from "./JavaScriptArtifactGraphEvidence.js";
|
|
6
8
|
import { resolveArtifactPathByContext, } from "./JavaScriptArtifactPathResolution.js";
|
|
@@ -58,6 +60,7 @@ export const addJavaScriptSourceModules = (context) => {
|
|
|
58
60
|
};
|
|
59
61
|
/** Compose bounded CommonJS and ESM binding relationships across artifact files. */
|
|
60
62
|
export const addJavaScriptModuleRelationships = (context) => {
|
|
63
|
+
const omissions = { selfImports: 0 };
|
|
61
64
|
for (const analyzed of context.analysis.files) {
|
|
62
65
|
const { file, semantic } = analyzed;
|
|
63
66
|
const source = context.sourceModuleNodes.get(file.path);
|
|
@@ -66,16 +69,17 @@ export const addJavaScriptModuleRelationships = (context) => {
|
|
|
66
69
|
for (const link of semantic.ir.moduleLinks) {
|
|
67
70
|
const input = { context, file, semantic, source, link };
|
|
68
71
|
if (isExportLink(link))
|
|
69
|
-
addExportRelationship(input);
|
|
72
|
+
addExportRelationship(input, omissions);
|
|
70
73
|
else if (link.specifier !== null)
|
|
71
|
-
addImportRelationship(input, source, {
|
|
74
|
+
addImportRelationship(input, source, omissions, {
|
|
72
75
|
specifier: link.specifier,
|
|
73
76
|
importedPath: link.importedName === null ? [] : [link.importedName],
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
}
|
|
80
|
+
return omissions;
|
|
77
81
|
};
|
|
78
|
-
const addExportRelationship = (input) => {
|
|
82
|
+
const addExportRelationship = (input, omissions) => {
|
|
79
83
|
const { context, file, semantic, source, link } = input;
|
|
80
84
|
if (link.exportedName === null)
|
|
81
85
|
return;
|
|
@@ -137,10 +141,18 @@ const addExportRelationship = (input) => {
|
|
|
137
141
|
});
|
|
138
142
|
const origin = moduleOriginForExport(semantic.ir, link);
|
|
139
143
|
if (origin !== null)
|
|
140
|
-
addImportRelationship(input, exported, origin);
|
|
144
|
+
addImportRelationship(input, exported, omissions, origin);
|
|
141
145
|
};
|
|
142
|
-
const addImportRelationship = (input, source, origin) => {
|
|
146
|
+
const addImportRelationship = (input, source, omissions, origin) => {
|
|
143
147
|
const target = resolveModuleTarget(input, origin.specifier);
|
|
148
|
+
// A specifier that resolves back to the importing module itself (a literal
|
|
149
|
+
// self-import, self-require, or artifact-confined path alias)
|
|
150
|
+
// cannot become an edge: the application graph forbids self-referential
|
|
151
|
+
// edges, and emitting one fails result validation for the whole analysis.
|
|
152
|
+
if (target.node.node_id === source.node_id) {
|
|
153
|
+
omissions.selfImports += 1;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
144
156
|
input.context.accumulator.addEdge({
|
|
145
157
|
source_node_id: source.node_id,
|
|
146
158
|
target_node_id: target.node.node_id,
|
|
@@ -242,12 +254,29 @@ const relationshipEvidence = (input, operation, limitations, confidence = "high"
|
|
|
242
254
|
operation,
|
|
243
255
|
coverage: semanticCoverage(input.semantic),
|
|
244
256
|
confidence,
|
|
245
|
-
limitations: [
|
|
257
|
+
limitations: [
|
|
258
|
+
...input.semantic.ir.limitations,
|
|
259
|
+
...semanticCoverageResourceLimits(input.semantic.ir.coverage).map(semanticResourceLimitReason),
|
|
260
|
+
...limitations,
|
|
261
|
+
],
|
|
246
262
|
});
|
|
247
263
|
const semanticCoverage = (semantic) => {
|
|
248
|
-
|
|
264
|
+
const resourceLimits = semanticCoverageResourceLimits(semantic.ir.coverage);
|
|
265
|
+
if (semantic.ir.coverage.status === "complete" && resourceLimits.length === 0)
|
|
249
266
|
return completeApplicationCoverage();
|
|
250
|
-
return partialApplicationCoverage(
|
|
267
|
+
return partialApplicationCoverage(resourceLimits.map((resourceLimit) => ({
|
|
268
|
+
name: `javascript_semantic_${resourceLimit.replaceAll("-", "_")}`,
|
|
269
|
+
value: resourceLimit === "primitive-candidates"
|
|
270
|
+
? SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT
|
|
271
|
+
: resourceLimit === "primitive-bytes"
|
|
272
|
+
? SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT
|
|
273
|
+
: SEMANTIC_EXPRESSION_DEPTH_LIMIT,
|
|
274
|
+
unit: resourceLimit === "expression-depth"
|
|
275
|
+
? "depth"
|
|
276
|
+
: resourceLimit === "primitive-bytes"
|
|
277
|
+
? "bytes"
|
|
278
|
+
: "items",
|
|
279
|
+
})), semantic.ir.coverage.omittedCount);
|
|
251
280
|
};
|
|
252
281
|
const moduleFormat = (path, ir) => {
|
|
253
282
|
const extension = posix.extname(path).toLowerCase();
|
|
@@ -3,7 +3,7 @@ import { AnalysisCancelledError, AnalysisInputError, AnalysisOutputError, } from
|
|
|
3
3
|
import { createEvidence } from "../../domain/evidence.js";
|
|
4
4
|
import { javascriptRecoveryInputSchema, javascriptRecoveryResultSchema, } from "../../domain/javascript/javascriptRecovery.js";
|
|
5
5
|
import { jsonObjectSchema } from "../../domain/jsonValue.js";
|
|
6
|
-
import {
|
|
6
|
+
import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js";
|
|
7
7
|
import { err, ok } from "../../domain/result.js";
|
|
8
8
|
const OPERATION = "recover_javascript_sources";
|
|
9
9
|
/** Shared CLI/MCP parsing and Evidence for derived JavaScript artifacts. */
|
|
@@ -18,7 +18,9 @@ export class JavaScriptRecoveryService {
|
|
|
18
18
|
return err(new AnalysisCancelledError(OPERATION));
|
|
19
19
|
const parsed = javascriptRecoveryInputSchema.safeParse(input);
|
|
20
20
|
if (!parsed.success)
|
|
21
|
-
return err(
|
|
21
|
+
return err(analysisInputErrorFromIssues(OPERATION, parsed.error.issues, input, {
|
|
22
|
+
cause: parsed.error,
|
|
23
|
+
}));
|
|
22
24
|
const invalidPaths = ["path", "output_directory"].filter((field) => !isAbsolute(parsed.data[field]));
|
|
23
25
|
if (invalidPaths.length > 0)
|
|
24
26
|
return err(new AnalysisInputError(OPERATION, undefined, invalidPaths.map((field) => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createJavaScriptRuntimeObservationEvidence } from "./JavaScriptRuntimeObservationEvidence.js";
|
|
2
|
-
import { AnalysisCapabilityUnavailableError } from "../../domain/analysisErrorCore.js";
|
|
2
|
+
import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, } from "../../domain/analysisErrorCore.js";
|
|
3
3
|
import {} from "../../domain/analysisErrorBase.js";
|
|
4
4
|
import { err, ok } from "../../domain/result.js";
|
|
5
5
|
/** List targets exposed by the explicitly selected loopback Inspector. */
|
|
@@ -18,6 +18,8 @@ export const observeJavaScriptRuntime = async (provider, input, options = {}) =>
|
|
|
18
18
|
if (!ready.ok)
|
|
19
19
|
return ready;
|
|
20
20
|
const result = await ready.value.observe(input, options);
|
|
21
|
+
if (options.signal?.aborted === true)
|
|
22
|
+
return err(new AnalysisCancelledError("observe_javascript_runtime"));
|
|
21
23
|
return result.ok
|
|
22
24
|
? ok(createJavaScriptRuntimeObservationEvidence("observe_javascript_runtime", input, result.value, ready.value.identity()))
|
|
23
25
|
: result;
|
|
@@ -2,7 +2,7 @@ import { resolve } from "node:path";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { AnalysisInputError, AnalysisProtocolError, } from "../../domain/analysisErrorCore.js";
|
|
4
4
|
import {} from "../../domain/analysisErrorBase.js";
|
|
5
|
-
import {
|
|
5
|
+
import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js";
|
|
6
6
|
import { reconcileJavaScriptRuntime } from "../../domain/javascript/javascriptRuntimeReconciliation.js";
|
|
7
7
|
import { reconcileJavaScriptRuntimeInputSchema } from "../../domain/javascript/javascriptRuntimeReconciliationSchemas.js";
|
|
8
8
|
import { err, ok } from "../../domain/result.js";
|
|
@@ -12,7 +12,7 @@ const OPERATION = "reconcile_javascript_runtime";
|
|
|
12
12
|
export const reconcileJavaScriptRuntimeEvidence = (rawInput) => {
|
|
13
13
|
const parsed = reconcileJavaScriptRuntimeInputSchema.safeParse(rawInput);
|
|
14
14
|
if (!parsed.success)
|
|
15
|
-
return err(
|
|
15
|
+
return err(analysisInputErrorFromIssues(OPERATION, parsed.error.issues, rawInput));
|
|
16
16
|
return reconcileJavaScriptRuntimeEvidenceValidated(parsed.data);
|
|
17
17
|
};
|
|
18
18
|
/** Reconcile input already parsed by a trusted adapter boundary. */
|
|
@@ -24,7 +24,7 @@ export const reconcileJavaScriptRuntimeEvidenceValidated = (parsedInput) => {
|
|
|
24
24
|
}
|
|
25
25
|
catch (cause) {
|
|
26
26
|
if (cause instanceof z.ZodError)
|
|
27
|
-
return err(
|
|
27
|
+
return err(analysisInputErrorFromIssues(OPERATION, cause.issues, parsedInput));
|
|
28
28
|
if (cause instanceof TypeError &&
|
|
29
29
|
SAFE_RECONCILIATION_INPUT_CONSTRAINTS.has(cause.message))
|
|
30
30
|
return err(new AnalysisInputError(OPERATION, undefined, [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createJavaScriptSemanticGraph, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
1
|
+
import { createJavaScriptSemanticGraph, createImmutableJavaScriptSemanticGraphSteps, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
2
|
import { JAVASCRIPT_SEMANTIC_RELATION_FAMILIES, JAVASCRIPT_SEMANTIC_RELATION_FAMILY, } from "../../domain/javascript/javascriptSemanticGraphSchemas.js";
|
|
3
3
|
import { sourceRangesEqual as rangesEqual } from "../../domain/javascript/javascriptStaticAnalysisHelpers.js";
|
|
4
4
|
import { projectSemanticEvents, projectSemanticTimers, } from "./JavaScriptSemanticGraphAsyncProjection.js";
|
|
@@ -68,68 +68,70 @@ export const createJavaScriptSemanticGraphProjection = () => {
|
|
|
68
68
|
truncatedFiles += 1;
|
|
69
69
|
state.fileNodeBudget = null;
|
|
70
70
|
};
|
|
71
|
+
const finishWith = (factory, rootArtifactSha256, applicationGraph, analysis) => {
|
|
72
|
+
bindSemanticGraphApplicationNodes(state, applicationGraph);
|
|
73
|
+
if (state.roots.size === 0)
|
|
74
|
+
addFallbackRoot(rootArtifactSha256, state);
|
|
75
|
+
const unknowns = [...state.unknowns.values()];
|
|
76
|
+
const graph = factory({
|
|
77
|
+
schema: "JavaScriptSemanticRelationGraph",
|
|
78
|
+
root_artifact_sha256: rootArtifactSha256,
|
|
79
|
+
application_graph_id: applicationGraph.graph_id,
|
|
80
|
+
root_node_ids: [...state.roots],
|
|
81
|
+
nodes: [...state.nodes.values()],
|
|
82
|
+
relations: [...state.relations.values()],
|
|
83
|
+
fingerprints,
|
|
84
|
+
unknowns,
|
|
85
|
+
coverage: {
|
|
86
|
+
status: truncatedFiles > 0 ? "partial" : "unknown",
|
|
87
|
+
truncated: truncatedFiles > 0,
|
|
88
|
+
omitted_nodes: truncatedFiles > 0 ? null : 0,
|
|
89
|
+
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
90
|
+
limits: truncatedFiles > 0
|
|
91
|
+
? [
|
|
92
|
+
{
|
|
93
|
+
name: "semantic_graph_node_ceiling",
|
|
94
|
+
value: SEMANTIC_GRAPH_NODE_CEILING,
|
|
95
|
+
unit: "items",
|
|
96
|
+
},
|
|
97
|
+
]
|
|
98
|
+
: [],
|
|
99
|
+
families: JAVASCRIPT_SEMANTIC_RELATION_FAMILIES.map((family) => ({
|
|
100
|
+
family,
|
|
101
|
+
status: semanticFamilyStatus(family, analysis),
|
|
102
|
+
retained_relations: [...state.relations.values()].filter((relation) => JAVASCRIPT_SEMANTIC_RELATION_FAMILY[relation.relation] ===
|
|
103
|
+
family).length,
|
|
104
|
+
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
105
|
+
unknown_ids: unknowns
|
|
106
|
+
.filter((unknown) => unknown.family === family)
|
|
107
|
+
.map(({ unknown_id: identifier }) => identifier),
|
|
108
|
+
})),
|
|
109
|
+
},
|
|
110
|
+
limitations: [
|
|
111
|
+
"The semantic graph contains static syntax observations and conservative relationship candidates; it does not claim runtime execution.",
|
|
112
|
+
"Local data flow does not claim control-flow-sensitive reaching definitions or arbitrary dynamic property resolution.",
|
|
113
|
+
"Promise ownership covers explicit unshadowed Promise construction, static factories, aggregation, chaining, and await syntax only.",
|
|
114
|
+
"Function fingerprints are static candidates; equal digests can remain ambiguous and do not prove behavioral equivalence.",
|
|
115
|
+
"Event extraction covers EventEmitter-style literal registrations, removals, and dispatch candidates; dynamic names remain unknown.",
|
|
116
|
+
"Timer extraction covers global or node:timers scheduling and exact local-handle cancellation.",
|
|
117
|
+
"Child-process extraction covers asynchronous node:child_process creation, literal argv/env/stdio options, exit/error listeners, and kill signals.",
|
|
118
|
+
"Configuration extraction covers process.env, process.argv, node:fs reads, and direct logical defaults.",
|
|
119
|
+
"Request extraction covers fetch, WebSocket, node:http/node:https construction, direct option fields, and exact local response consumers.",
|
|
120
|
+
"Boundary extraction covers unshadowed JSON/global coercions plus parse and validation method candidates.",
|
|
121
|
+
"Resource extraction covers built-in filesystem/network acquisition and exact local close/destroy/end handles.",
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
state.nodes.clear();
|
|
125
|
+
state.relations.clear();
|
|
126
|
+
state.unknowns.clear();
|
|
127
|
+
state.roots.clear();
|
|
128
|
+
fingerprints.length = 0;
|
|
129
|
+
return graph;
|
|
130
|
+
};
|
|
71
131
|
return {
|
|
72
132
|
projectFile: projectSource,
|
|
73
|
-
finish: (rootArtifactSha256, applicationGraph, analysis) =>
|
|
74
|
-
|
|
75
|
-
if (state.roots.size === 0)
|
|
76
|
-
addFallbackRoot(rootArtifactSha256, state);
|
|
77
|
-
const unknowns = [...state.unknowns.values()];
|
|
78
|
-
const graph = createJavaScriptSemanticGraph({
|
|
79
|
-
schema: "JavaScriptSemanticRelationGraph",
|
|
80
|
-
root_artifact_sha256: rootArtifactSha256,
|
|
81
|
-
application_graph_id: applicationGraph.graph_id,
|
|
82
|
-
root_node_ids: [...state.roots],
|
|
83
|
-
nodes: [...state.nodes.values()],
|
|
84
|
-
relations: [...state.relations.values()],
|
|
85
|
-
fingerprints,
|
|
86
|
-
unknowns,
|
|
87
|
-
coverage: {
|
|
88
|
-
status: truncatedFiles > 0 ? "partial" : "unknown",
|
|
89
|
-
truncated: truncatedFiles > 0,
|
|
90
|
-
omitted_nodes: truncatedFiles > 0 ? null : 0,
|
|
91
|
-
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
92
|
-
limits: truncatedFiles > 0
|
|
93
|
-
? [
|
|
94
|
-
{
|
|
95
|
-
name: "semantic_graph_node_ceiling",
|
|
96
|
-
value: SEMANTIC_GRAPH_NODE_CEILING,
|
|
97
|
-
unit: "items",
|
|
98
|
-
},
|
|
99
|
-
]
|
|
100
|
-
: [],
|
|
101
|
-
families: JAVASCRIPT_SEMANTIC_RELATION_FAMILIES.map((family) => ({
|
|
102
|
-
family,
|
|
103
|
-
status: semanticFamilyStatus(family, analysis),
|
|
104
|
-
retained_relations: [...state.relations.values()].filter((relation) => JAVASCRIPT_SEMANTIC_RELATION_FAMILY[relation.relation] ===
|
|
105
|
-
family).length,
|
|
106
|
-
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
107
|
-
unknown_ids: unknowns
|
|
108
|
-
.filter((unknown) => unknown.family === family)
|
|
109
|
-
.map(({ unknown_id: identifier }) => identifier),
|
|
110
|
-
})),
|
|
111
|
-
},
|
|
112
|
-
limitations: [
|
|
113
|
-
"The semantic graph contains static syntax observations and conservative relationship candidates; it does not claim runtime execution.",
|
|
114
|
-
"Local data flow does not claim control-flow-sensitive reaching definitions or arbitrary dynamic property resolution.",
|
|
115
|
-
"Promise ownership covers explicit unshadowed Promise construction, static factories, aggregation, chaining, and await syntax only.",
|
|
116
|
-
"Function fingerprints are static candidates; equal digests can remain ambiguous and do not prove behavioral equivalence.",
|
|
117
|
-
"Event extraction covers EventEmitter-style literal registrations, removals, and dispatch candidates; dynamic names remain unknown.",
|
|
118
|
-
"Timer extraction covers global or node:timers scheduling and exact local-handle cancellation.",
|
|
119
|
-
"Child-process extraction covers asynchronous node:child_process creation, literal argv/env/stdio options, exit/error listeners, and kill signals.",
|
|
120
|
-
"Configuration extraction covers process.env, process.argv, node:fs reads, and direct logical defaults.",
|
|
121
|
-
"Request extraction covers fetch, WebSocket, node:http/node:https construction, direct option fields, and exact local response consumers.",
|
|
122
|
-
"Boundary extraction covers unshadowed JSON/global coercions plus parse and validation method candidates.",
|
|
123
|
-
"Resource extraction covers built-in filesystem/network acquisition and exact local close/destroy/end handles.",
|
|
124
|
-
],
|
|
125
|
-
});
|
|
126
|
-
state.nodes.clear();
|
|
127
|
-
state.relations.clear();
|
|
128
|
-
state.unknowns.clear();
|
|
129
|
-
state.roots.clear();
|
|
130
|
-
fingerprints.length = 0;
|
|
131
|
-
return graph;
|
|
132
|
-
},
|
|
133
|
+
finish: (rootArtifactSha256, applicationGraph, analysis) => finishWith(createJavaScriptSemanticGraph, rootArtifactSha256, applicationGraph, analysis),
|
|
134
|
+
finishImmutableSteps: (rootArtifactSha256, applicationGraph, analysis) => finishWith(createImmutableJavaScriptSemanticGraphSteps, rootArtifactSha256, applicationGraph, analysis),
|
|
133
135
|
};
|
|
134
136
|
};
|
|
135
137
|
const projectFile = (file, ir, state) => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createJavaScriptSemanticGraphUnknown } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
|
+
import { retainSemanticGraphNode, addSemanticGraphRelation, addSemanticGraphUnknown, } from "./JavaScriptSemanticGraphConstruction.js";
|
|
3
|
+
import { observedSemanticEvidence } from "./JavaScriptSemanticGraphEvidence.js";
|
|
2
4
|
/** Project bounded literal values and object slots for exact query seeds. */
|
|
3
5
|
export const projectSemanticValues = (context) => {
|
|
4
6
|
for (const binding of context.ir.bindings) {
|
|
@@ -54,6 +56,26 @@ const projectValue = (input) => {
|
|
|
54
56
|
role: `property:${property.name}`,
|
|
55
57
|
});
|
|
56
58
|
}
|
|
59
|
+
else if (value.status === "unknown" && value.resourceLimit !== undefined) {
|
|
60
|
+
const location = binding.definitions[0]?.location ?? null;
|
|
61
|
+
const evidence = observedSemanticEvidence(context.file, location);
|
|
62
|
+
const isPropertyValue = role.startsWith("property:");
|
|
63
|
+
addSemanticGraphUnknown(context.state, createJavaScriptSemanticGraphUnknown({
|
|
64
|
+
node_id: target.node_id,
|
|
65
|
+
family: isPropertyValue ? "object-flow" : "data-flow",
|
|
66
|
+
relation_kinds: [isPropertyValue ? "writes-property" : "defines"],
|
|
67
|
+
reason: "resource-limit",
|
|
68
|
+
detail: `${value.reason} Unknown value at ${role}.`,
|
|
69
|
+
candidate_node_ids: [target.node_id],
|
|
70
|
+
evidence: {
|
|
71
|
+
...evidence,
|
|
72
|
+
authority: "unknown",
|
|
73
|
+
state: "unknown",
|
|
74
|
+
confidence: "unknown",
|
|
75
|
+
limitations: [value.reason],
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
57
79
|
};
|
|
58
80
|
const addLiteralNode = (context, binding, value, role) => retainSemanticGraphNode(context.state, context.file, {
|
|
59
81
|
kind: "literal",
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AnalysisProtocolError } from "../../domain/analysisErrorCore.js";
|
|
3
3
|
import {} from "../../domain/analysisErrorBase.js";
|
|
4
4
|
import { createEvidence } from "../../domain/evidence.js";
|
|
5
5
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
6
6
|
import { managedApplicationGraphResultSchema, projectManagedApplicationGraph, projectManagedApplicationGraphInputSchema, } from "../../domain/managed/managedApplicationGraph.js";
|
|
7
7
|
import { err, ok } from "../../domain/result.js";
|
|
8
8
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
|
9
|
+
import { requestInputError, workflowInputError, } from "../workflowInputError.js";
|
|
9
10
|
const OPERATION = "project_managed_application_graph";
|
|
10
11
|
/** Project authenticated managed Evidence into a provider-neutral graph. */
|
|
11
12
|
export const projectManagedApplicationGraphEvidence = (rawInput) => {
|
|
12
13
|
const parsed = projectManagedApplicationGraphInputSchema.safeParse(rawInput);
|
|
13
14
|
if (!parsed.success)
|
|
14
|
-
return err(
|
|
15
|
+
return err(requestInputError(OPERATION, parsed.error, rawInput));
|
|
15
16
|
try {
|
|
16
17
|
const result = projectManagedApplicationGraph(parsed.data);
|
|
17
18
|
return ok(createManagedApplicationGraphEvidence(parsed.data, result));
|
|
18
19
|
}
|
|
19
20
|
catch (cause) {
|
|
20
21
|
return err(cause instanceof TypeError || cause instanceof z.ZodError
|
|
21
|
-
?
|
|
22
|
+
? workflowInputError(OPERATION, cause)
|
|
22
23
|
: new AnalysisProtocolError("Managed application graph projection produced an invalid result", { cause }));
|
|
23
24
|
}
|
|
24
25
|
};
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { compareManagedMembers, managedMemberComparisonResultSchema, parseManagedMemberEvidence, } from "../../domain/managed/managedMemberComparison.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AnalysisProtocolError } from "../../domain/analysisErrorCore.js";
|
|
6
6
|
import { EvidenceIntegrityError } from "../../domain/evidenceErrors.js";
|
|
7
7
|
import {} from "../../domain/analysisErrorBase.js";
|
|
8
8
|
import { createEvidence } from "../../domain/evidence.js";
|
|
@@ -11,6 +11,7 @@ import { parseBinaryTarget } from "../BinaryTargetResolver.js";
|
|
|
11
11
|
import { err, ok } from "../../domain/result.js";
|
|
12
12
|
import { inspectManagedMembersBytes } from "../../dotnet/ManagedMemberInspector.js";
|
|
13
13
|
import { MANAGED_STATIC_PROVIDER, MANAGED_WORKFLOW_PROVIDER, } from "../InvestigationProviders.js";
|
|
14
|
+
import { workflowInputError } from "../workflowInputError.js";
|
|
14
15
|
/** Compare managed members from input parsed by a trusted adapter. */
|
|
15
16
|
export const compareManagedMembersEvidenceValidated = (input) => {
|
|
16
17
|
const operation = "compare_managed_members";
|
|
@@ -36,10 +37,12 @@ export const compareManagedMemberPaths = async (input, dependencies = DEFAULT_PA
|
|
|
36
37
|
dependencies.resolveTarget(input.leftPath),
|
|
37
38
|
dependencies.resolveTarget(input.rightPath),
|
|
38
39
|
]);
|
|
40
|
+
// Report an unopenable path like every other path-based command does,
|
|
41
|
+
// with the failed path and constraint, rather than a bare input error.
|
|
39
42
|
if (!leftTarget.ok)
|
|
40
|
-
return err(
|
|
43
|
+
return err(leftTarget.error);
|
|
41
44
|
if (!rightTarget.ok)
|
|
42
|
-
return err(
|
|
45
|
+
return err(rightTarget.error);
|
|
43
46
|
const [leftBytes, rightBytes] = await Promise.all([
|
|
44
47
|
dependencies.readBytes(leftTarget.value.path),
|
|
45
48
|
dependencies.readBytes(rightTarget.value.path),
|
|
@@ -103,5 +106,5 @@ const createManagedMemberComparisonEvidence = (parameters, result) => createEvid
|
|
|
103
106
|
evidenceLinks: result.evidence_links,
|
|
104
107
|
});
|
|
105
108
|
const workflowFailure = (operation, cause) => err(cause instanceof z.ZodError || cause instanceof TypeError
|
|
106
|
-
?
|
|
109
|
+
? workflowInputError(operation, cause)
|
|
107
110
|
: new AnalysisProtocolError("Managed member comparison produced an invalid result", { cause }));
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AnalysisProtocolError } from "../../domain/analysisErrorCore.js";
|
|
3
3
|
import {} from "../../domain/analysisErrorBase.js";
|
|
4
4
|
import { createEvidence } from "../../domain/evidence.js";
|
|
5
5
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
6
6
|
import { managedNativeVerificationInputSchema, verifyManagedNativeBoundaries, } from "../../domain/managed/managedNativeVerification.js";
|
|
7
7
|
import { err, ok } from "../../domain/result.js";
|
|
8
8
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
|
9
|
+
import { requestInputError, workflowInputError, } from "../workflowInputError.js";
|
|
9
10
|
const OPERATION = "verify_managed_native_boundaries";
|
|
10
11
|
/** Verify managed/native boundary declarations against native Evidence. */
|
|
11
12
|
export const verifyManagedNativeBoundariesEvidence = (rawInput) => {
|
|
12
13
|
const parsed = managedNativeVerificationInputSchema.safeParse(rawInput);
|
|
13
14
|
if (!parsed.success)
|
|
14
|
-
return err(
|
|
15
|
+
return err(requestInputError(OPERATION, parsed.error, rawInput));
|
|
15
16
|
try {
|
|
16
17
|
const result = verifyManagedNativeBoundaries(parsed.data);
|
|
17
18
|
return ok(createManagedNativeVerificationEvidence(parsed.data, result));
|
|
18
19
|
}
|
|
19
20
|
catch (cause) {
|
|
20
21
|
return err(cause instanceof TypeError || cause instanceof z.ZodError
|
|
21
|
-
?
|
|
22
|
+
? workflowInputError(OPERATION, cause)
|
|
22
23
|
: new AnalysisProtocolError("Managed/native verification produced an invalid result", { cause }));
|
|
23
24
|
}
|
|
24
25
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AnalysisProtocolError } from "../../domain/analysisErrorCore.js";
|
|
3
3
|
import {} from "../../domain/analysisErrorBase.js";
|
|
4
4
|
import { createEvidence } from "../../domain/evidence.js";
|
|
5
5
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
6
6
|
import { importManagedReconstruction, managedReconstructionImportInputSchema, } from "../../domain/managed/managedReconstruction.js";
|
|
7
7
|
import { err, ok } from "../../domain/result.js";
|
|
8
8
|
import { MANAGED_WORKFLOW_PROVIDER } from "../InvestigationProviders.js";
|
|
9
|
+
import { requestInputError, workflowInputError, } from "../workflowInputError.js";
|
|
9
10
|
const OPERATION = "import_managed_reconstruction";
|
|
10
11
|
/** Authenticate and import managed decompiler reconstruction as Evidence. */
|
|
11
12
|
export const importManagedReconstructionEvidence = (rawInput) => {
|
|
12
13
|
const parsed = managedReconstructionImportInputSchema.safeParse(rawInput);
|
|
13
14
|
if (!parsed.success)
|
|
14
|
-
return err(
|
|
15
|
+
return err(requestInputError(OPERATION, parsed.error, rawInput));
|
|
15
16
|
return importManagedReconstructionEvidenceValidated(parsed.data);
|
|
16
17
|
};
|
|
17
18
|
/** Import reconstruction from input parsed by a trusted adapter. */
|
|
@@ -22,7 +23,7 @@ export const importManagedReconstructionEvidenceValidated = (input) => {
|
|
|
22
23
|
}
|
|
23
24
|
catch (cause) {
|
|
24
25
|
return err(cause instanceof TypeError || cause instanceof z.ZodError
|
|
25
|
-
?
|
|
26
|
+
? workflowInputError(OPERATION, cause)
|
|
26
27
|
: new AnalysisProtocolError("Managed reconstruction import produced an invalid result", { cause }));
|
|
27
28
|
}
|
|
28
29
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { AnalysisError } from "../../domain/analysisErrorBase.js";
|
|
3
4
|
import { AnalysisInputError } from "../../domain/analysisErrorCore.js";
|
|
4
5
|
import { projectAnalysisError } from "../../domain/analysisErrorProjection.js";
|
|
5
6
|
import { createEvidence, parseEvidence } from "../../domain/evidence.js";
|
|
7
|
+
import { describeValidationFailure } from "../../domain/evidenceBundle.js";
|
|
6
8
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
7
|
-
import { projectInputIssues } from "../../domain/inputIssueProjection.js";
|
|
9
|
+
import { analysisInputErrorFromIssues, projectInputIssues, } from "../../domain/inputIssueProjection.js";
|
|
8
10
|
import { processTraceSpecificationSchema } from "../../domain/process/processTraceComparison.js";
|
|
9
11
|
import { processScenarioSchema } from "../../domain/process/processScenario.js";
|
|
10
12
|
import { compareProcessCaptures, parseProcessCapture, } from "../../domain/process/processCapture.js";
|
|
@@ -25,7 +27,7 @@ export const captureProcessScenarioFile = async (path, environment = process.env
|
|
|
25
27
|
const input = await readJson(path);
|
|
26
28
|
const parsed = processScenarioSchema.safeParse(input);
|
|
27
29
|
if (!parsed.success)
|
|
28
|
-
throw
|
|
30
|
+
throw analysisInputErrorFromIssues("capture_process_scenario", parsed.error.issues, input, { cause: parsed.error });
|
|
29
31
|
const captured = await captureProcessScenario(parsed.data, undefined, process.platform, environment);
|
|
30
32
|
if (!captured.ok)
|
|
31
33
|
return cliAnalysisError(captured.error);
|
|
@@ -78,7 +80,9 @@ const parseCaptureEvidence = (input) => {
|
|
|
78
80
|
evidence = parseEvidence(input);
|
|
79
81
|
}
|
|
80
82
|
catch (cause) {
|
|
81
|
-
|
|
83
|
+
if (cause instanceof z.ZodError)
|
|
84
|
+
throw new AnalysisInputError("compare_process_captures", { cause }, projectInputIssues(cause.issues, input));
|
|
85
|
+
throw invalidCaptureEvidence(cause);
|
|
82
86
|
}
|
|
83
87
|
if (evidence.operation !== "capture_process_scenario" ||
|
|
84
88
|
evidence.predicate_type !== "rea.process-capture" ||
|
|
@@ -94,16 +98,20 @@ const parseCaptureEvidence = (input) => {
|
|
|
94
98
|
};
|
|
95
99
|
}
|
|
96
100
|
catch (cause) {
|
|
97
|
-
throw invalidCaptureEvidence();
|
|
101
|
+
throw invalidCaptureEvidence(cause);
|
|
98
102
|
}
|
|
99
103
|
};
|
|
100
104
|
const parseTraceSpecification = (input) => {
|
|
101
105
|
const parsed = processTraceSpecificationSchema.safeParse(input);
|
|
102
106
|
if (parsed.success)
|
|
103
107
|
return parsed.data;
|
|
104
|
-
|
|
108
|
+
// Match the MCP boundary: the operation name and a trace_spec-rooted path.
|
|
109
|
+
throw new AnalysisInputError("compare_process_captures", { cause: parsed.error }, projectInputIssues(parsed.error.issues, input).map((issue) => ({
|
|
110
|
+
...issue,
|
|
111
|
+
path: ["trace_spec", ...issue.path],
|
|
112
|
+
})));
|
|
105
113
|
};
|
|
106
|
-
const invalidCaptureEvidence = () => new ProcessCliFailure("invalid_input",
|
|
114
|
+
const invalidCaptureEvidence = (cause) => new ProcessCliFailure("invalid_input", `Capture evidence is malformed (${describeValidationFailure(cause)}). Create new capture evidence, then try again.`);
|
|
107
115
|
const readJson = async (path) => {
|
|
108
116
|
let bytes;
|
|
109
117
|
try {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { posix, win32 } from "node:path";
|
|
1
2
|
import { createEvidence } from "../../domain/evidence.js";
|
|
2
3
|
import { PROCESS_PROVIDER } from "../../domain/process/processEvidenceProvider.js";
|
|
3
4
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
4
5
|
export { PROCESS_PROVIDER } from "../../domain/process/processEvidenceProvider.js";
|
|
5
6
|
/** Project one process scenario into secret-free Evidence parameters. */
|
|
6
|
-
const processEvidenceParameters = (scenario) => ({
|
|
7
|
-
executable_name:
|
|
7
|
+
const processEvidenceParameters = (scenario, platform) => ({
|
|
8
|
+
executable_name: (platform === "win32" ? win32 : posix).basename(scenario.executable),
|
|
8
9
|
argument_count: scenario.arguments.length,
|
|
9
10
|
event_count: scenario.events.length,
|
|
10
11
|
filesystem_observation_path_count: scenario.filesystem_observation_paths.length,
|
|
@@ -15,7 +16,7 @@ export const createProcessCaptureEvidence = (scenario, capture) => {
|
|
|
15
16
|
return createEvidence(undefined, PROCESS_PROVIDER, {
|
|
16
17
|
predicateType: "rea.process-capture",
|
|
17
18
|
operation: "capture_process_scenario",
|
|
18
|
-
parameters: processEvidenceParameters(scenario),
|
|
19
|
+
parameters: processEvidenceParameters(scenario, capture.manifest.platform),
|
|
19
20
|
result: jsonValueSchema.parse(capture),
|
|
20
21
|
confidence: "observed",
|
|
21
22
|
authority: "controlled-replay",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
3
|
+
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
4
|
+
/** Project schema issues of the raw request onto their request paths. */
|
|
5
|
+
export const requestInputError = (operation, cause, input) => analysisInputErrorFromIssues(operation, cause.issues, input, { cause });
|
|
6
|
+
/**
|
|
7
|
+
* Keep the failed constraint when a parsed request is rejected later. Nested
|
|
8
|
+
* values such as Evidence results are parsed on their own, so their issue
|
|
9
|
+
* paths are relative to that value and are reported in the message, not as
|
|
10
|
+
* request paths.
|
|
11
|
+
*/
|
|
12
|
+
export const workflowInputError = (operation, cause) => new AnalysisInputError(operation, { cause }, cause instanceof z.ZodError
|
|
13
|
+
? cause.issues.map((issue) => ({
|
|
14
|
+
path: [],
|
|
15
|
+
reason: "invalid_value",
|
|
16
|
+
message: `A nested value failed validation at ${issue.path.length === 0 ? "its root" : issue.path.map(String).join(".")}: ${issue.message}`,
|
|
17
|
+
}))
|
|
18
|
+
: [{ path: [], reason: "invalid_value", message: cause.message }]);
|
|
@@ -7,7 +7,7 @@ import { extractArtifact } from "./extraction/ArtifactExtraction.js";
|
|
|
7
7
|
import { analyzeInterfaceBuilderBundle } from "./apple/InterfaceBuilderAnalysis.js";
|
|
8
8
|
import { analyzeAppleAssetCatalogs } from "./apple/AppleAssetCatalogAnalysis.js";
|
|
9
9
|
import { ARTIFACT_ANALYSIS_OPERATIONS, artifactInventoryInputSchema, artifactExtractionExecutionSchema, } from "../contracts/artifactToolContracts.js";
|
|
10
|
-
import { AnalysisCapabilityUnavailableError } from "../domain/analysisErrorCore.js";
|
|
10
|
+
import { AnalysisCapabilityUnavailableError, AnalysisInputError, } from "../domain/analysisErrorCore.js";
|
|
11
11
|
import { ArtifactOperationError } from "../domain/artifactOperationError.js";
|
|
12
12
|
import {} from "../domain/analysisErrorBase.js";
|
|
13
13
|
import { interfaceBuilderLimitsSchema } from "../domain/apple/interfaceBuilderGraph.js";
|
|
@@ -74,7 +74,14 @@ class ArtifactClient {
|
|
|
74
74
|
parameters.path !== undefined &&
|
|
75
75
|
parameters.path !== "." &&
|
|
76
76
|
parameters.path !== basename(this.target.path))
|
|
77
|
-
throw new
|
|
77
|
+
throw new AnalysisInputError(operation, undefined, [
|
|
78
|
+
{
|
|
79
|
+
path: ["path"],
|
|
80
|
+
reason: "invalid_value",
|
|
81
|
+
message: "For an active plist, path must select that archive (omit path or use its basename).",
|
|
82
|
+
expected: basename(this.target.path),
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
78
85
|
const bundlePath = standalone
|
|
79
86
|
? dirname(this.target.path)
|
|
80
87
|
: this.target.sourcePath;
|
|
@@ -233,6 +240,9 @@ const isArtifactOperation = (operation) => ARTIFACT_ANALYSIS_OPERATIONS.includes
|
|
|
233
240
|
const translateFailure = (operation, cause) => {
|
|
234
241
|
if (cause instanceof ArtifactReaderFailure)
|
|
235
242
|
return new ArtifactOperationError(operation, cause.reason, cause.details, cause.message);
|
|
243
|
+
// Caller-selection failures are already typed; keep their correction details.
|
|
244
|
+
if (cause instanceof AnalysisInputError)
|
|
245
|
+
return cause;
|
|
236
246
|
return new ArtifactOperationError(operation, "io");
|
|
237
247
|
};
|
|
238
248
|
const subjectFor = (path, manifest) => ({
|