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,10 +1,11 @@
|
|
|
1
1
|
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
|
2
2
|
import { AnalysisError } from "../../domain/analysisErrorBase.js";
|
|
3
|
-
import { AnalysisAccessDeniedError, AnalysisArtifactChangedError, AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisInputError, AnalysisOutputError, AnalysisTimeoutError, } from "../../domain/analysisErrorCore.js";
|
|
3
|
+
import { AnalysisAccessDeniedError, AnalysisArtifactChangedError, AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisInputError, AnalysisOutputError, AnalysisResourceConstraintError, AnalysisTimeoutError, } from "../../domain/analysisErrorCore.js";
|
|
4
4
|
import { ProviderAdapterError } from "../../domain/providerAdapterError.js";
|
|
5
5
|
import { ProviderCleanupError } from "../../domain/providerCleanupError.js";
|
|
6
6
|
import { WEB_NETWORK_CAPTURE_LIMITS, } from "../../domain/webNetworkCapture.js";
|
|
7
7
|
import { OwnedCommandFailure } from "../../process/OwnedCommand.js";
|
|
8
|
+
import { HAR_CAPTURE_HEAP_LIMITS } from "./CaptureRelease.js";
|
|
8
9
|
const OPERATION = "inspect_web_network_capture";
|
|
9
10
|
/** Preserve the origin and typed cause of a historical capture failure. */
|
|
10
11
|
export const historicalCaptureFailure = (input, cause, phase, options) => {
|
|
@@ -30,6 +31,12 @@ export const historicalCaptureFailure = (input, cause, phase, options) => {
|
|
|
30
31
|
return new AnalysisTimeoutError(OPERATION, WEB_NETWORK_CAPTURE_LIMITS.timeoutMs);
|
|
31
32
|
if (cause.reason === "output-limit")
|
|
32
33
|
return new AnalysisOutputError(OPERATION, cause.message);
|
|
34
|
+
if (phase === "decoder" &&
|
|
35
|
+
input.format === "har" &&
|
|
36
|
+
cause.reason === "process" &&
|
|
37
|
+
cause.snapshot?.signal === "SIGABRT" &&
|
|
38
|
+
/FATAL ERROR:[^\r\n]*heap out of memory/u.test(cause.snapshot.stderr.text))
|
|
39
|
+
return captureMemoryFailure(input, "The HAR decoder exhausted its fixed V8 heap", cause);
|
|
33
40
|
}
|
|
34
41
|
if (options?.signal?.aborted)
|
|
35
42
|
return new AnalysisCancelledError(OPERATION);
|
|
@@ -99,3 +106,32 @@ export const historicalCaptureFailure = (input, cause, phase, options) => {
|
|
|
99
106
|
},
|
|
100
107
|
});
|
|
101
108
|
};
|
|
109
|
+
/** Preserve a decoder's observed memory failure and its actual workload limits. */
|
|
110
|
+
export const captureMemoryFailure = (input, reason, cause) => new AnalysisResourceConstraintError(OPERATION, "memory", `${reason}: ${input.capture_path}. No complete capture result is available.`, {
|
|
111
|
+
boundary: "historical-capture-decoder",
|
|
112
|
+
capture_path: input.capture_path,
|
|
113
|
+
format: input.format,
|
|
114
|
+
maximum_input_bytes: WEB_NETWORK_CAPTURE_LIMITS.inputBytes,
|
|
115
|
+
maximum_reply_bytes: WEB_NETWORK_CAPTURE_LIMITS.outputBytes,
|
|
116
|
+
...(input.format === "har"
|
|
117
|
+
? {
|
|
118
|
+
old_generation_heap_mib: HAR_CAPTURE_HEAP_LIMITS.oldGenerationMiB,
|
|
119
|
+
semi_space_heap_mib: HAR_CAPTURE_HEAP_LIMITS.semiSpaceMiB,
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
122
|
+
...(cause instanceof OwnedCommandFailure
|
|
123
|
+
? { observed_signal: cause.snapshot?.signal ?? null }
|
|
124
|
+
: {}),
|
|
125
|
+
}, {
|
|
126
|
+
cause,
|
|
127
|
+
remediationAction: `Use a smaller capture exported by its producer, or another decoder with sufficient capacity for the original capture. Preserve the original for provenance; a subset does not establish complete-capture coverage.${input.format === "har" ? ` REA's HAR old-generation heap is fixed at ${HAR_CAPTURE_HEAP_LIMITS.oldGenerationMiB} MiB; inherited NODE_OPTIONS cannot raise it.` : ""}`,
|
|
128
|
+
...(cause instanceof OwnedCommandFailure && cause.snapshot !== null
|
|
129
|
+
? {
|
|
130
|
+
capturedOutput: {
|
|
131
|
+
stdout: cause.snapshot.stdout.text,
|
|
132
|
+
stderr: cause.snapshot.stderr.text,
|
|
133
|
+
truncated: cause.snapshot.diagnosticTruncated ?? false,
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
: {}),
|
|
137
|
+
});
|
|
@@ -4,6 +4,11 @@ export const HAR_CAPTURE_PROVIDER_IDENTITY = {
|
|
|
4
4
|
name: "REA HAR capture adapter",
|
|
5
5
|
version: "har-schema@2.0.0;jsonc-parser@3.3.1;lossless-json@4.3.1",
|
|
6
6
|
};
|
|
7
|
+
/** Fixed V8 heap settings used by the owned HAR decoder process. */
|
|
8
|
+
export const HAR_CAPTURE_HEAP_LIMITS = {
|
|
9
|
+
oldGenerationMiB: 192,
|
|
10
|
+
semiSpaceMiB: 8,
|
|
11
|
+
};
|
|
7
12
|
/** Native executable profile verified with unchanged mitmproxy raw-state decoding. */
|
|
8
13
|
export const MITMPROXY_CAPTURE_PROVIDER_IDENTITY = {
|
|
9
14
|
id: "mitmproxy-native-tnetstring",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { HAR_CAPTURE_PROVIDER_IDENTITY } from "./CaptureRelease.js";
|
|
2
|
+
import { HAR_CAPTURE_PROVIDER_IDENTITY, HAR_CAPTURE_HEAP_LIMITS, } from "./CaptureRelease.js";
|
|
3
3
|
/** HAR's parser/schema packages run in one bounded Node heap, without network or target execution. */
|
|
4
4
|
export class HarCaptureAdapter {
|
|
5
5
|
format = "har";
|
|
@@ -8,8 +8,8 @@ export class HarCaptureAdapter {
|
|
|
8
8
|
return {
|
|
9
9
|
command: process.execPath,
|
|
10
10
|
arguments: [
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
`--max-old-space-size=${HAR_CAPTURE_HEAP_LIMITS.oldGenerationMiB}`,
|
|
12
|
+
`--max-semi-space-size=${HAR_CAPTURE_HEAP_LIMITS.semiSpaceMiB}`,
|
|
13
13
|
"--v8-pool-size=1",
|
|
14
14
|
"--single-threaded",
|
|
15
15
|
fileURLToPath(new URL("./HarCaptureProcess.js", import.meta.url)),
|
|
@@ -43,8 +43,9 @@ export const parseHarJson = (text) => {
|
|
|
43
43
|
});
|
|
44
44
|
},
|
|
45
45
|
onObjectProperty: (key) => {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// Prototype-named members are kept as ordinary own properties: the
|
|
47
|
+
// members map keys them without prototype setters, and
|
|
48
|
+
// Object.fromEntries materializes them as own data properties.
|
|
48
49
|
const frame = frames.at(-1);
|
|
49
50
|
if (frame?.kind !== "object")
|
|
50
51
|
throw new TypeError("JSON visitor emitted a property outside an object.");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { historicalCaptureFailure } from "./CaptureFailures.js";
|
|
1
|
+
import { historicalCaptureFailure, captureMemoryFailure, } from "./CaptureFailures.js";
|
|
2
2
|
import { projectAnalysisError } from "../../domain/analysisErrorProjection.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { writeFile } from "node:fs/promises";
|
|
@@ -117,7 +117,9 @@ export class HistoricalCaptureDecoder {
|
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
119
|
]);
|
|
120
|
-
if (reply.reason === "
|
|
120
|
+
if (reply.reason === "resource-limit")
|
|
121
|
+
throw captureMemoryFailure(input, reply.message);
|
|
122
|
+
if (reply.reason === "decoder")
|
|
121
123
|
throw new ProviderAdapterError(input.format, OPERATION, {
|
|
122
124
|
diagnostics: {
|
|
123
125
|
phase: "decoder",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
2
|
+
/** Preserve a CLI selector supplied positionally or through its named option. */
|
|
3
|
+
export const resolveCliAnalysisSelector = (positional, named, option, operation) => {
|
|
4
|
+
if (positional !== undefined && named !== undefined && positional !== named)
|
|
5
|
+
throw new AnalysisInputError(operation, undefined, [
|
|
6
|
+
{
|
|
7
|
+
path: [option],
|
|
8
|
+
reason: "invalid_value",
|
|
9
|
+
message: `The positional selector and --${option} select different objects; supply one selector.`,
|
|
10
|
+
},
|
|
11
|
+
]);
|
|
12
|
+
const selected = named ?? positional;
|
|
13
|
+
if (selected === undefined)
|
|
14
|
+
throw new AnalysisInputError(operation, undefined, [
|
|
15
|
+
{
|
|
16
|
+
path: [option],
|
|
17
|
+
reason: "missing_argument",
|
|
18
|
+
message: `Supply a positional selector or --${option}=<value>. Use the named option for values beginning with a dash.`,
|
|
19
|
+
expected: "string",
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
return selected;
|
|
23
|
+
};
|
|
@@ -9,7 +9,6 @@ import { buildReconstructionObligationLedgerEvidenceValidated } from "../applica
|
|
|
9
9
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
10
10
|
import { parseCliJsonInput } from "../cliJsonInput.js";
|
|
11
11
|
import { logCliCommand } from "../cliLogging.js";
|
|
12
|
-
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
13
12
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
14
13
|
import {} from "../domain/analysisErrorBase.js";
|
|
15
14
|
import { androidApplicationProjectionInputSchema } from "../domain/android/androidApplication.js";
|
|
@@ -20,7 +19,7 @@ import { traceJavaScriptSemanticsInputSchema } from "../domain/javascript/javasc
|
|
|
20
19
|
import { compareApplicationVersionsInputSchema } from "../domain/javascript/javascriptApplicationVersionComparisonSchemas.js";
|
|
21
20
|
import { compareSourceToBundleInputSchema } from "../domain/javascript/sourceToBundleComparisonSchemas.js";
|
|
22
21
|
import { compareJavaScriptExportShapesInputSchema } from "../domain/javascript/javascriptExportShapeComparisonSchemas.js";
|
|
23
|
-
import {
|
|
22
|
+
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
24
23
|
import { reconstructionObligationLedgerInputSchema } from "../domain/reconstructionObligationLedgerSchemas.js";
|
|
25
24
|
/** Register CLI equivalents of provider-neutral application graph workflows. */
|
|
26
25
|
export const registerApplicationCommands = (cli, logger) => {
|
|
@@ -133,7 +132,7 @@ const registerJsonCommand = ({ cli, logger, name, description, inputSchema, work
|
|
|
133
132
|
if (!parsed.success)
|
|
134
133
|
return {
|
|
135
134
|
error: "Application workflow failed",
|
|
136
|
-
...projectAnalysisError(
|
|
135
|
+
...projectAnalysisError(analysisInputErrorFromIssues(name, parsed.error.issues, input.value)),
|
|
137
136
|
};
|
|
138
137
|
const result = workflow(parsed.data);
|
|
139
138
|
return result.ok
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "incur";
|
|
2
2
|
import { stat } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
|
+
import { resolveCliAnalysisSelector } from "./analysisSelector.js";
|
|
4
5
|
import { runDirectAnalysis } from "../composition/directAnalysis.js";
|
|
5
6
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
6
7
|
import { logCliCommand } from "../cliLogging.js";
|
|
@@ -9,6 +10,7 @@ import { runCliJavaScriptApplicationAnalysis } from "./javascriptApplicationAnal
|
|
|
9
10
|
/** Register provider-neutral binary overview and procedure CLI commands. */
|
|
10
11
|
export const registerCoreBinaryCommands = (cli, logger, resultOutput) => {
|
|
11
12
|
registerOverviewCommands(cli, logger, resultOutput);
|
|
13
|
+
registerDecompileCommand(cli, logger);
|
|
12
14
|
registerFunctionCommand(cli, logger);
|
|
13
15
|
registerInstructionsCommand(cli, logger);
|
|
14
16
|
registerSearchCommand(cli, logger);
|
|
@@ -43,13 +45,24 @@ const registerOverviewCommands = (cli, logger, resultOutput) => {
|
|
|
43
45
|
options: overviewOptions,
|
|
44
46
|
run: ({ args, options }) => logCliCommand(logger, "inspect", () => runDirectAnalysis(args.path, "binary_overview", {}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
45
47
|
});
|
|
48
|
+
};
|
|
49
|
+
const registerDecompileCommand = (cli, logger) => {
|
|
46
50
|
cli.command(CLI_COMMANDS.decompile, {
|
|
47
51
|
description: "Read one part of an app as code",
|
|
48
52
|
args: z.object({
|
|
49
53
|
path: z.string().describe("App or program path"),
|
|
50
|
-
address: z
|
|
54
|
+
address: z
|
|
55
|
+
.string()
|
|
56
|
+
.min(1)
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Procedure name or address"),
|
|
51
59
|
}),
|
|
52
60
|
options: z.object({
|
|
61
|
+
procedure: z
|
|
62
|
+
.string()
|
|
63
|
+
.min(1)
|
|
64
|
+
.optional()
|
|
65
|
+
.describe("Procedure name or address; use --procedure=<value> for leading dashes"),
|
|
53
66
|
snapshot: z
|
|
54
67
|
.string()
|
|
55
68
|
.min(1)
|
|
@@ -58,7 +71,9 @@ const registerOverviewCommands = (cli, logger, resultOutput) => {
|
|
|
58
71
|
"target-format": formatSelectionOption,
|
|
59
72
|
provider: providerSelectionOption,
|
|
60
73
|
}),
|
|
61
|
-
run: ({ args, options }) => logCliCommand(logger, "decompile", () => runDirectAnalysis(args.path, "procedure_pseudo_code", {
|
|
74
|
+
run: ({ args, options }) => logCliCommand(logger, "decompile", () => runDirectAnalysis(args.path, "procedure_pseudo_code", {
|
|
75
|
+
procedure: resolveCliAnalysisSelector(args.address, options.procedure, "procedure", "procedure_pseudo_code"),
|
|
76
|
+
}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
62
77
|
});
|
|
63
78
|
};
|
|
64
79
|
const runRoutedOverview = async (path, options, logger, output) => {
|
|
@@ -90,9 +105,14 @@ const registerXrefsCommand = (cli, logger) => {
|
|
|
90
105
|
description: "List bounded references to an analyzed address",
|
|
91
106
|
args: z.object({
|
|
92
107
|
path: z.string().describe("App or program path"),
|
|
93
|
-
address: z.string().describe("
|
|
108
|
+
address: z.string().min(1).optional().describe("Address or symbol name"),
|
|
94
109
|
}),
|
|
95
110
|
options: z.object({
|
|
111
|
+
address: z
|
|
112
|
+
.string()
|
|
113
|
+
.min(1)
|
|
114
|
+
.optional()
|
|
115
|
+
.describe("Address or symbol name; use --address=<value> for leading dashes"),
|
|
96
116
|
snapshot: z
|
|
97
117
|
.string()
|
|
98
118
|
.min(1)
|
|
@@ -101,7 +121,9 @@ const registerXrefsCommand = (cli, logger) => {
|
|
|
101
121
|
"target-format": formatSelectionOption,
|
|
102
122
|
provider: providerSelectionOption,
|
|
103
123
|
}),
|
|
104
|
-
run: ({ args, options }) => logCliCommand(logger, "xrefs", () => runDirectAnalysis(args.path, "xrefs", {
|
|
124
|
+
run: ({ args, options }) => logCliCommand(logger, "xrefs", () => runDirectAnalysis(args.path, "xrefs", {
|
|
125
|
+
address: resolveCliAnalysisSelector(args.address, options.address, "address", "xrefs"),
|
|
126
|
+
}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
105
127
|
});
|
|
106
128
|
};
|
|
107
129
|
const registerTraceCommand = (cli, logger) => {
|
|
@@ -109,9 +131,14 @@ const registerTraceCommand = (cli, logger) => {
|
|
|
109
131
|
description: "Trace a literal feature through analyzed references",
|
|
110
132
|
args: z.object({
|
|
111
133
|
path: z.string().describe("App or program path"),
|
|
112
|
-
query: z.string().min(1).describe("Literal feature query"),
|
|
134
|
+
query: z.string().min(1).optional().describe("Literal feature query"),
|
|
113
135
|
}),
|
|
114
136
|
options: z.object({
|
|
137
|
+
query: z
|
|
138
|
+
.string()
|
|
139
|
+
.min(1)
|
|
140
|
+
.optional()
|
|
141
|
+
.describe("Complete literal feature query; use --query=<value> for leading dashes"),
|
|
115
142
|
caseSensitive: z
|
|
116
143
|
.boolean()
|
|
117
144
|
.default(false)
|
|
@@ -128,7 +155,7 @@ const registerTraceCommand = (cli, logger) => {
|
|
|
128
155
|
caseSensitive: "case-sensitive",
|
|
129
156
|
},
|
|
130
157
|
run: ({ args, options }) => logCliCommand(logger, "trace", () => runDirectAnalysis(args.path, "trace_feature", {
|
|
131
|
-
query: args.query,
|
|
158
|
+
query: resolveCliAnalysisSelector(args.query, options.query, "query", "trace_feature"),
|
|
132
159
|
case_sensitive: options.caseSensitive,
|
|
133
160
|
}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
134
161
|
});
|
|
@@ -138,9 +165,18 @@ const registerFunctionCommand = (cli, logger) => {
|
|
|
138
165
|
description: "Analyze one complete function with evidence",
|
|
139
166
|
args: z.object({
|
|
140
167
|
path: z.string().describe("App or program path"),
|
|
141
|
-
address: z
|
|
168
|
+
address: z
|
|
169
|
+
.string()
|
|
170
|
+
.min(1)
|
|
171
|
+
.optional()
|
|
172
|
+
.describe("Procedure name or address"),
|
|
142
173
|
}),
|
|
143
174
|
options: z.object({
|
|
175
|
+
procedure: z
|
|
176
|
+
.string()
|
|
177
|
+
.min(1)
|
|
178
|
+
.optional()
|
|
179
|
+
.describe("Procedure name or address; use --procedure=<value> for leading dashes"),
|
|
144
180
|
snapshot: z
|
|
145
181
|
.string()
|
|
146
182
|
.min(1)
|
|
@@ -149,7 +185,9 @@ const registerFunctionCommand = (cli, logger) => {
|
|
|
149
185
|
"target-format": formatSelectionOption,
|
|
150
186
|
provider: providerSelectionOption,
|
|
151
187
|
}),
|
|
152
|
-
run: ({ args, options }) => logCliCommand(logger, "function", () => runDirectAnalysis(args.path, "analyze_function", {
|
|
188
|
+
run: ({ args, options }) => logCliCommand(logger, "function", () => runDirectAnalysis(args.path, "analyze_function", {
|
|
189
|
+
procedure: resolveCliAnalysisSelector(args.address, options.procedure, "procedure", "analyze_function"),
|
|
190
|
+
}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
153
191
|
});
|
|
154
192
|
};
|
|
155
193
|
const registerInstructionsCommand = (cli, logger) => {
|
|
@@ -157,9 +195,18 @@ const registerInstructionsCommand = (cli, logger) => {
|
|
|
157
195
|
description: "Read every raw instruction without decompiling",
|
|
158
196
|
args: z.object({
|
|
159
197
|
path: z.string().describe("App or program path"),
|
|
160
|
-
address: z
|
|
198
|
+
address: z
|
|
199
|
+
.string()
|
|
200
|
+
.min(1)
|
|
201
|
+
.optional()
|
|
202
|
+
.describe("Procedure name or address"),
|
|
161
203
|
}),
|
|
162
204
|
options: z.object({
|
|
205
|
+
procedure: z
|
|
206
|
+
.string()
|
|
207
|
+
.min(1)
|
|
208
|
+
.optional()
|
|
209
|
+
.describe("Procedure name or address; use --procedure=<value> for leading dashes"),
|
|
163
210
|
snapshot: z
|
|
164
211
|
.string()
|
|
165
212
|
.min(1)
|
|
@@ -169,7 +216,7 @@ const registerInstructionsCommand = (cli, logger) => {
|
|
|
169
216
|
provider: providerSelectionOption,
|
|
170
217
|
}),
|
|
171
218
|
run: ({ args, options }) => logCliCommand(logger, CLI_COMMANDS.instructions, () => runDirectAnalysis(args.path, "read_function_instructions", {
|
|
172
|
-
procedure: args.address,
|
|
219
|
+
procedure: resolveCliAnalysisSelector(args.address, options.procedure, "procedure", "read_function_instructions"),
|
|
173
220
|
}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
174
221
|
});
|
|
175
222
|
};
|
|
@@ -178,9 +225,18 @@ const registerSearchCommand = (cli, logger) => {
|
|
|
178
225
|
description: "Search every analyzed string or procedure name",
|
|
179
226
|
args: z.object({
|
|
180
227
|
path: z.string().describe("App or program path"),
|
|
181
|
-
pattern: z
|
|
228
|
+
pattern: z
|
|
229
|
+
.string()
|
|
230
|
+
.min(1)
|
|
231
|
+
.optional()
|
|
232
|
+
.describe("Literal text or regex pattern"),
|
|
182
233
|
}),
|
|
183
234
|
options: z.object({
|
|
235
|
+
pattern: z
|
|
236
|
+
.string()
|
|
237
|
+
.min(1)
|
|
238
|
+
.optional()
|
|
239
|
+
.describe("Complete literal text or regex pattern; use --pattern=<value> for leading dashes"),
|
|
184
240
|
kind: z
|
|
185
241
|
.enum(["strings", "procedures"])
|
|
186
242
|
.default("strings")
|
|
@@ -203,7 +259,9 @@ const registerSearchCommand = (cli, logger) => {
|
|
|
203
259
|
}),
|
|
204
260
|
alias: { caseSensitive: "case-sensitive" },
|
|
205
261
|
run: ({ args, options }) => logCliCommand(logger, "search", () => runDirectAnalysis(args.path, options.kind === "strings" ? "search_strings" : "search_procedures", {
|
|
206
|
-
pattern: args.pattern,
|
|
262
|
+
pattern: resolveCliAnalysisSelector(args.pattern, options.pattern, "pattern", options.kind === "strings"
|
|
263
|
+
? "search_strings"
|
|
264
|
+
: "search_procedures"),
|
|
207
265
|
mode: options.mode,
|
|
208
266
|
case_sensitive: options.caseSensitive,
|
|
209
267
|
}, directAnalysisOptions(logger, options.snapshot, options.provider, options["target-format"]))),
|
|
@@ -12,6 +12,7 @@ import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
|
12
12
|
import { parseCliJsonInput, resolveCliJsonPaths } from "../cliJsonInput.js";
|
|
13
13
|
import { electronPageInspectionOptions, javascriptApplicationOptions, } from "../cliObservationOptions.js";
|
|
14
14
|
import { runCliJavaScriptApplicationAnalysis } from "./javascriptApplicationAnalysis.js";
|
|
15
|
+
import { withCommandCancellation } from "./commandCancellation.js";
|
|
15
16
|
/** Register CLI equivalents of the Electron MCP tools. */
|
|
16
17
|
export const registerElectronCommands = (cli, logger, resultOutput) => {
|
|
17
18
|
registerElectronObservationCommands(cli, logger);
|
|
@@ -21,13 +22,13 @@ export const registerElectronCommands = (cli, logger, resultOutput) => {
|
|
|
21
22
|
};
|
|
22
23
|
const registerElectronActiveCommand = (cli, logger) => {
|
|
23
24
|
cli.command(CLI_COMMANDS.captureElectronScenario, {
|
|
24
|
-
description: "Run one
|
|
25
|
+
description: "Run one owned Electron scenario with cancellable actions",
|
|
25
26
|
args: z.object({
|
|
26
27
|
inputJson: z
|
|
27
28
|
.string()
|
|
28
29
|
.describe("Inline JSON or a JSON file matching capture_electron_scenario"),
|
|
29
30
|
}),
|
|
30
|
-
run: ({ args }) => logCliCommand(logger, CLI_COMMANDS.captureElectronScenario, async () => {
|
|
31
|
+
run: ({ args }) => withCommandCancellation((signal) => logCliCommand(logger, CLI_COMMANDS.captureElectronScenario, async () => {
|
|
31
32
|
const input = await parseCliJsonInput(args.inputJson, "capture_electron_scenario");
|
|
32
33
|
if (!input.ok)
|
|
33
34
|
return input.error;
|
|
@@ -39,9 +40,9 @@ const registerElectronActiveCommand = (cli, logger) => {
|
|
|
39
40
|
if (!parsed.success)
|
|
40
41
|
return inputError("capture_electron_scenario", parsed.error.issues, input.value);
|
|
41
42
|
const { createElectronScenarioProvider } = await import("../composition/electronScenario.js");
|
|
42
|
-
const result = await captureElectronScenario(createElectronScenarioProvider(), parsed.data);
|
|
43
|
+
const result = await captureElectronScenario(createElectronScenarioProvider(), parsed.data, { signal });
|
|
43
44
|
return result.ok ? result.value : cliError(result.error);
|
|
44
|
-
}),
|
|
45
|
+
})),
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
48
|
const registerJavaScriptRuntimeReconciliationCommand = (cli, logger) => {
|
|
@@ -113,13 +114,13 @@ const registerJavaScriptApplicationCommand = (cli, logger, resultOutput) => {
|
|
|
113
114
|
path: z.string().describe("ASAR or extracted application path"),
|
|
114
115
|
}),
|
|
115
116
|
options: javascriptApplicationOptions,
|
|
116
|
-
run: ({ args, options, format }) => logCliCommand(logger, CLI_COMMANDS.analyzeJavaScriptApplication, () => runCliJavaScriptApplicationAnalysis({ input_path: args.path, format: options.artifactFormat }, resultOutput === undefined
|
|
117
|
+
run: ({ args, options, format }) => withCommandCancellation((signal) => logCliCommand(logger, CLI_COMMANDS.analyzeJavaScriptApplication, () => runCliJavaScriptApplicationAnalysis({ input_path: args.path, format: options.artifactFormat }, resultOutput === undefined
|
|
117
118
|
? undefined
|
|
118
119
|
: {
|
|
119
120
|
output: resultOutput,
|
|
120
121
|
command: CLI_COMMANDS.analyzeJavaScriptApplication,
|
|
121
122
|
format,
|
|
122
|
-
})),
|
|
123
|
+
}, signal))),
|
|
123
124
|
});
|
|
124
125
|
};
|
|
125
126
|
const electronObservationContext = async () => {
|
|
@@ -2,12 +2,15 @@ import { analyzeJavaScriptApplication } from "../application/javascript/JavaScri
|
|
|
2
2
|
import { createProgressReporter } from "../application/ProgressReporter.js";
|
|
3
3
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
4
4
|
/** Execute the shared one-shot CLI boundary for static JavaScript analysis. */
|
|
5
|
-
export const runCliJavaScriptApplicationAnalysis = async (input, output) => {
|
|
5
|
+
export const runCliJavaScriptApplicationAnalysis = async (input, output, signal) => {
|
|
6
6
|
const started = performance.now();
|
|
7
7
|
const progress = createProgressReporter(async (update) => {
|
|
8
8
|
process.stderr.write(`${JSON.stringify({ rea_progress: update })}\n`);
|
|
9
9
|
}, { minimumIntervalMs: 0 });
|
|
10
|
-
const result = await analyzeJavaScriptApplication(input, {
|
|
10
|
+
const result = await analyzeJavaScriptApplication(input, {
|
|
11
|
+
progress,
|
|
12
|
+
...(signal === undefined ? {} : { signal }),
|
|
13
|
+
});
|
|
11
14
|
const value = result.ok ? result.value : cliError(result.error);
|
|
12
15
|
if (output !== undefined &&
|
|
13
16
|
(await output.output.write(value, {
|
|
@@ -15,7 +18,8 @@ export const runCliJavaScriptApplicationAnalysis = async (input, output) => {
|
|
|
15
18
|
format: output.format,
|
|
16
19
|
duration: `${Math.round(performance.now() - started)}ms`,
|
|
17
20
|
})))
|
|
18
|
-
|
|
21
|
+
// Keep failures visible to command logging after the stream has handled stdout.
|
|
22
|
+
return result.ok ? undefined : value;
|
|
19
23
|
return value;
|
|
20
24
|
};
|
|
21
25
|
const cliError = (error) => ({
|
package/dist/cli/jsonOutput.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { bufferedJsonParts, jsonParts } from "../domain/jsonSerialization.js";
|
|
1
2
|
/** Write ordinary JSON without constructing a document-sized string. */
|
|
2
3
|
export const writeJsonOutput = async (value, destination, format = "json") => {
|
|
3
|
-
for (const part of
|
|
4
|
+
for (const part of bufferedJsonParts(documentParts(value, format)))
|
|
4
5
|
await writePart(destination, part);
|
|
5
6
|
};
|
|
6
7
|
const writePart = (destination, part) => new Promise((resolve, reject) => {
|
|
@@ -27,107 +28,11 @@ const writePart = (destination, part) => new Promise((resolve, reject) => {
|
|
|
27
28
|
function* documentParts(value, format) {
|
|
28
29
|
if (format === "jsonl" && Array.isArray(value)) {
|
|
29
30
|
for (const item of value) {
|
|
30
|
-
yield*
|
|
31
|
+
yield* jsonParts(item);
|
|
31
32
|
yield "\n";
|
|
32
33
|
}
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
yield*
|
|
36
|
+
yield* jsonParts(value, format === "json");
|
|
36
37
|
yield "\n";
|
|
37
38
|
}
|
|
38
|
-
function* bufferedParts(parts) {
|
|
39
|
-
let buffer = "";
|
|
40
|
-
for (const part of parts) {
|
|
41
|
-
if (buffer.length + part.length > 64 * 1024 && buffer !== "") {
|
|
42
|
-
yield buffer;
|
|
43
|
-
buffer = "";
|
|
44
|
-
}
|
|
45
|
-
buffer += part;
|
|
46
|
-
}
|
|
47
|
-
if (buffer !== "")
|
|
48
|
-
yield buffer;
|
|
49
|
-
}
|
|
50
|
-
function* encodeString(value) {
|
|
51
|
-
if (value.length <= 8192) {
|
|
52
|
-
yield JSON.stringify(value);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
yield '"';
|
|
56
|
-
for (let start = 0; start < value.length;) {
|
|
57
|
-
let end = Math.min(start + 8192, value.length);
|
|
58
|
-
const last = value.charCodeAt(end - 1);
|
|
59
|
-
const next = value.charCodeAt(end);
|
|
60
|
-
// Keep a surrogate pair in the same JSON.stringify and UTF-8 write.
|
|
61
|
-
if (end < value.length &&
|
|
62
|
-
last >= 0xd800 &&
|
|
63
|
-
last <= 0xdbff &&
|
|
64
|
-
next >= 0xdc00 &&
|
|
65
|
-
next <= 0xdfff)
|
|
66
|
-
end -= 1;
|
|
67
|
-
yield JSON.stringify(value.slice(start, end)).slice(1, -1);
|
|
68
|
-
start = end;
|
|
69
|
-
}
|
|
70
|
-
yield '"';
|
|
71
|
-
}
|
|
72
|
-
function* encodeValue(value, pretty, depth, ancestors) {
|
|
73
|
-
if (typeof value === "string") {
|
|
74
|
-
yield* encodeString(value);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (value === null || typeof value === "boolean") {
|
|
78
|
-
yield value === null ? "null" : String(value);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
82
|
-
yield String(value);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (typeof value !== "object" || value === null)
|
|
86
|
-
throw new TypeError("CLI JSON output requires ordinary JSON values");
|
|
87
|
-
if (ancestors.has(value))
|
|
88
|
-
throw new TypeError("CLI JSON output contains a circular reference");
|
|
89
|
-
if (!Array.isArray(value) &&
|
|
90
|
-
Object.prototype.toString.call(value) !== "[object Object]")
|
|
91
|
-
throw new TypeError("CLI JSON output requires ordinary JSON objects");
|
|
92
|
-
ancestors.add(value);
|
|
93
|
-
try {
|
|
94
|
-
const array = Array.isArray(value);
|
|
95
|
-
const keys = array
|
|
96
|
-
? undefined
|
|
97
|
-
: Object.keys(value).filter((key) => {
|
|
98
|
-
const item = Reflect.get(value, key);
|
|
99
|
-
// Incur's filter can select inherited methods. Match native JSON's
|
|
100
|
-
// omission of fields that have no JSON representation.
|
|
101
|
-
return (item !== undefined &&
|
|
102
|
-
typeof item !== "function" &&
|
|
103
|
-
typeof item !== "symbol");
|
|
104
|
-
});
|
|
105
|
-
const count = array ? value.length : (keys?.length ?? 0);
|
|
106
|
-
yield array ? "[" : "{";
|
|
107
|
-
for (let index = 0; index < count; index += 1) {
|
|
108
|
-
if (index > 0)
|
|
109
|
-
yield ",";
|
|
110
|
-
if (pretty)
|
|
111
|
-
yield `\n${" ".repeat(depth + 1)}`;
|
|
112
|
-
let item;
|
|
113
|
-
if (array) {
|
|
114
|
-
item = value[index];
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
const key = keys?.[index];
|
|
118
|
-
if (key === undefined)
|
|
119
|
-
throw new TypeError("CLI JSON object changed during serialization");
|
|
120
|
-
yield* encodeString(key);
|
|
121
|
-
yield pretty ? ": " : ":";
|
|
122
|
-
item = Reflect.get(value, key);
|
|
123
|
-
}
|
|
124
|
-
yield* encodeValue(item, pretty, depth + 1, ancestors);
|
|
125
|
-
}
|
|
126
|
-
if (pretty && count > 0)
|
|
127
|
-
yield `\n${" ".repeat(depth)}`;
|
|
128
|
-
yield array ? "]" : "}";
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
ancestors.delete(value);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -3,9 +3,8 @@ import { runProviderAnalysis } from "../composition/directAnalysis.js";
|
|
|
3
3
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
4
4
|
import { parseCliJsonInput } from "../cliJsonInput.js";
|
|
5
5
|
import { logCliCommand } from "../cliLogging.js";
|
|
6
|
-
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
7
6
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
8
|
-
import {
|
|
7
|
+
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
9
8
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
10
9
|
import { nativeCallObservationInputSchema } from "../domain/native/nativeCallObservation.js";
|
|
11
10
|
const OPERATION = "observe_native_calls";
|
|
@@ -27,7 +26,7 @@ export const registerNativeCallCommands = (cli, logger) => {
|
|
|
27
26
|
if (!parsed.success)
|
|
28
27
|
return {
|
|
29
28
|
error: "Analysis failed",
|
|
30
|
-
...projectAnalysisError(
|
|
29
|
+
...projectAnalysisError(analysisInputErrorFromIssues(OPERATION, parsed.error.issues, input.value)),
|
|
31
30
|
};
|
|
32
31
|
return runProviderAnalysis(args.path, OPERATION, z.record(z.string(), jsonValueSchema).parse(parsed.data), logger);
|
|
33
32
|
}),
|
|
@@ -25,15 +25,15 @@ export const registerWebRuntimeCommands = (cli, logger) => {
|
|
|
25
25
|
...browserScopeOptions,
|
|
26
26
|
observationMs: observationDuration(10_000, 1),
|
|
27
27
|
}),
|
|
28
|
-
run: ({ args, options }) => logCliCommand(logger, "observe-web-execution", async () => {
|
|
29
|
-
const result = await
|
|
28
|
+
run: ({ args, options }) => withCommandCancellation((signal) => logCliCommand(logger, "observe-web-execution", async () => {
|
|
29
|
+
const result = await createWebRuntimeService().observe({
|
|
30
30
|
cdp_endpoint: args.endpoint,
|
|
31
31
|
target_id: args.targetId,
|
|
32
32
|
allowed_origins: options.allowedOrigins,
|
|
33
33
|
observation_ms: options.observationMs,
|
|
34
|
-
}, { progress: runtimeProgress, signal })
|
|
34
|
+
}, { progress: runtimeProgress, signal });
|
|
35
35
|
return result.ok ? result.value : browserCliError(result.error);
|
|
36
|
-
}),
|
|
36
|
+
})),
|
|
37
37
|
});
|
|
38
38
|
cli.command(CLI_COMMANDS.inspectWebEventListeners, {
|
|
39
39
|
description: "Inspect native listener source locations on the first main-document CSS match",
|
|
@@ -47,14 +47,14 @@ export const registerWebRuntimeCommands = (cli, logger) => {
|
|
|
47
47
|
.describe("Native CSS selector; inspect the first main-document match"),
|
|
48
48
|
}),
|
|
49
49
|
options: z.object({ ...browserScopeOptions }),
|
|
50
|
-
run: ({ args, options }) => logCliCommand(logger, "inspect-web-event-listeners", async () => {
|
|
51
|
-
const result = await
|
|
50
|
+
run: ({ args, options }) => withCommandCancellation((signal) => logCliCommand(logger, "inspect-web-event-listeners", async () => {
|
|
51
|
+
const result = await createWebRuntimeService().inspect({
|
|
52
52
|
cdp_endpoint: args.endpoint,
|
|
53
53
|
target_id: args.targetId,
|
|
54
54
|
selector: args.selector,
|
|
55
55
|
allowed_origins: options.allowedOrigins,
|
|
56
|
-
}, { signal })
|
|
56
|
+
}, { signal });
|
|
57
57
|
return result.ok ? result.value : browserCliError(result.error);
|
|
58
|
-
}),
|
|
58
|
+
})),
|
|
59
59
|
});
|
|
60
60
|
};
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { registerBinaryDiagnosticsCommands } from "./cli/binaryDiagnosticsComman
|
|
|
3
3
|
import { Cli } from "incur";
|
|
4
4
|
import { createLogger, parseLogLevel } from "./logger.js";
|
|
5
5
|
import { PRODUCT_IDENTITY } from "./identity.js";
|
|
6
|
+
import { npxRegistrationCommand } from "./application/ClientRegistrationIdentity.js";
|
|
6
7
|
import { registerSetupCommands } from "./cli/setupCommands.js";
|
|
7
8
|
import { registerCoreAnalysisCommands } from "./cli/coreAnalysisCommands.js";
|
|
8
9
|
import { registerUtilityCommands } from "./cli/utilityCommands.js";
|
|
@@ -37,7 +38,7 @@ export const createCli = (environment = process.env, resultOutput) => {
|
|
|
37
38
|
version: PRODUCT_IDENTITY.packageVersion,
|
|
38
39
|
description: "Reverse engineer anything from your terminal or agent.",
|
|
39
40
|
mcp: {
|
|
40
|
-
command:
|
|
41
|
+
command: npxRegistrationCommand().join(" "),
|
|
41
42
|
instructions: "Ask what software, artifact, protocol, or behavior the user wants to understand, then choose the available investigation capabilities that can produce evidence.",
|
|
42
43
|
},
|
|
43
44
|
sync: false,
|
package/dist/cliCommandNames.js
CHANGED