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,3 +1,4 @@
|
|
|
1
|
+
import { issue } from "./AppleDispatchDecodeFacts.js";
|
|
1
2
|
const hex = (value) => `0x${value.toString(16)}`;
|
|
2
3
|
const decoded = { status: "decoded", reason: null };
|
|
3
4
|
/** Create a Swift ABI signed-relative pointer decoder that records relative_pointers. */
|
|
@@ -42,7 +43,9 @@ export const createSwiftRelativeReader = (input) => {
|
|
|
42
43
|
export const decodeSwiftDispatchFacets = (input) => {
|
|
43
44
|
const { sections, segments, readers: read, relative, budget, result } = input;
|
|
44
45
|
const swiftFailures = [];
|
|
46
|
+
const issues = [];
|
|
45
47
|
let swiftExamined = 0;
|
|
48
|
+
let decodedRecords = 0;
|
|
46
49
|
for (const section of sections.filter(({ name }) => name === "__swift5_proto")) {
|
|
47
50
|
if (section.size % 4 !== 0)
|
|
48
51
|
throw new RangeError("Misaligned Swift conformance section");
|
|
@@ -77,6 +80,9 @@ export const decodeSwiftDispatchFacets = (input) => {
|
|
|
77
80
|
if (staticWitness && read.pointer(witness) !== descriptor)
|
|
78
81
|
witnessReason =
|
|
79
82
|
"Witness-table conformance header is unresolved or encoded";
|
|
83
|
+
const conformanceDecode = witnessReason === null
|
|
84
|
+
? { status: "decoded", reason: null }
|
|
85
|
+
: { status: "partial", reason: witnessReason };
|
|
80
86
|
result.swift_conformances.push({
|
|
81
87
|
type_name: typeName,
|
|
82
88
|
protocol_name: protocolName,
|
|
@@ -85,16 +91,14 @@ export const decodeSwiftDispatchFacets = (input) => {
|
|
|
85
91
|
? { address: null, file_offset: null }
|
|
86
92
|
: read.location(witness),
|
|
87
93
|
location: read.location(descriptor),
|
|
88
|
-
decode:
|
|
89
|
-
? decoded
|
|
90
|
-
: {
|
|
91
|
-
status: "partial",
|
|
92
|
-
reason: witnessReason,
|
|
93
|
-
},
|
|
94
|
+
decode: conformanceDecode,
|
|
94
95
|
evidence: read.evidence(descriptor, "Swift protocol conformance descriptor and directly encoded type/protocol names"),
|
|
95
96
|
});
|
|
97
|
+
if (conformanceDecode.status === "decoded")
|
|
98
|
+
decodedRecords++;
|
|
96
99
|
if (witnessReason !== null) {
|
|
97
100
|
swiftFailures.push(`${typeName}: ${witnessReason}`);
|
|
101
|
+
issues.push(issue("swift_conformances_static_witness_slots", "conformance_decode_partial", witnessReason, hex(descriptor)));
|
|
98
102
|
continue;
|
|
99
103
|
}
|
|
100
104
|
const count = read.u32(protocol + 16n);
|
|
@@ -113,6 +117,12 @@ export const decodeSwiftDispatchFacets = (input) => {
|
|
|
113
117
|
segments.some((segment) => segment.executable &&
|
|
114
118
|
implementation >= segment.address &&
|
|
115
119
|
implementation < segment.address + segment.size);
|
|
120
|
+
const slotDecode = executable
|
|
121
|
+
? { status: "decoded", reason: null }
|
|
122
|
+
: {
|
|
123
|
+
status: "partial",
|
|
124
|
+
reason: "Witness slot is non-function, async, nil, external, authenticated or encoded; implementation target is unresolved",
|
|
125
|
+
};
|
|
116
126
|
result.swift_dispatch_slots.push({
|
|
117
127
|
owner: `${typeName}: ${protocolName}`,
|
|
118
128
|
table_kind: "witness_table",
|
|
@@ -122,29 +132,25 @@ export const decodeSwiftDispatchFacets = (input) => {
|
|
|
122
132
|
implementation_address: executable ? hex(implementation) : null,
|
|
123
133
|
thunk_address: null,
|
|
124
134
|
location: read.location(entry),
|
|
125
|
-
decode:
|
|
126
|
-
? decoded
|
|
127
|
-
: {
|
|
128
|
-
status: "partial",
|
|
129
|
-
reason: "Witness slot is non-function, async, nil, external, authenticated or encoded; implementation target is unresolved",
|
|
130
|
-
},
|
|
135
|
+
decode: slotDecode,
|
|
131
136
|
evidence: read.evidence(entry, "Static Swift witness slot, indexed after the conformance-descriptor header"),
|
|
132
137
|
});
|
|
138
|
+
if (slotDecode.status !== "decoded")
|
|
139
|
+
issues.push(issue("swift_conformances_static_witness_slots", "witness_slot_unresolved", slotDecode.reason, hex(entry)));
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
catch (cause) {
|
|
136
|
-
|
|
143
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
144
|
+
swiftFailures.push(`${hex(field)}: ${message}`);
|
|
145
|
+
issues.push(issue("swift_conformances_static_witness_slots", "conformance_decode_failed", message, hex(field)));
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
}
|
|
140
|
-
|
|
149
|
+
return {
|
|
141
150
|
facet: "swift_conformances_static_witness_slots",
|
|
142
|
-
status: swiftFailures.length > 0 || budget.truncated ? "partial" : "complete",
|
|
143
|
-
reason: [
|
|
144
|
-
...swiftFailures,
|
|
145
|
-
...(budget.truncated ? ["max_records_reached"] : []),
|
|
146
|
-
].join("; ") || null,
|
|
147
151
|
examined: swiftExamined,
|
|
148
|
-
decoded:
|
|
149
|
-
|
|
152
|
+
decoded: decodedRecords,
|
|
153
|
+
exhaustive: !budget.truncated && issues.length === 0,
|
|
154
|
+
issues,
|
|
155
|
+
};
|
|
150
156
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { issue } from "./AppleDispatchDecodeFacts.js";
|
|
1
2
|
/** Decode non-generic, non-resilient Swift class vtable descriptors without instantiating metadata. */
|
|
2
3
|
export const decodeSwiftClassVtables = (input) => {
|
|
3
4
|
const { readers: read, result } = input;
|
|
4
5
|
const failures = [];
|
|
6
|
+
const issues = [];
|
|
5
7
|
let examined = 0;
|
|
8
|
+
let decoded = 0;
|
|
6
9
|
for (const field of input.entries) {
|
|
7
10
|
if (!read.admit()) {
|
|
8
11
|
failures.push("max_records_reached");
|
|
12
|
+
issues.push(issue("swift_class_vtable_descriptors", "record_budget_exhausted", "max_records_reached", `0x${field.toString(16)}`));
|
|
9
13
|
break;
|
|
10
14
|
}
|
|
11
15
|
examined++;
|
|
@@ -32,11 +36,12 @@ export const decodeSwiftClassVtables = (input) => {
|
|
|
32
36
|
throw new RangeError("Swift vtable count or offset exceeds declared metadata bounds");
|
|
33
37
|
const owner = read.string(read.relative(descriptor + 8n));
|
|
34
38
|
for (let index = 0; index < count; index++) {
|
|
39
|
+
const entry = header + 8n + BigInt(index * 8);
|
|
35
40
|
if (!read.admit()) {
|
|
36
41
|
failures.push("max_records_reached");
|
|
42
|
+
issues.push(issue("swift_class_vtable_descriptors", "record_budget_exhausted", "max_records_reached", `0x${entry.toString(16)}`));
|
|
37
43
|
break;
|
|
38
44
|
}
|
|
39
|
-
const entry = header + 8n + BigInt(index * 8);
|
|
40
45
|
const methodFlags = read.u32(entry);
|
|
41
46
|
// Async slots reference async descriptors; coroutine and future kinds need separate decoders.
|
|
42
47
|
const synchronous = (methodFlags & 0x40) === 0 && (methodFlags & 15) <= 3;
|
|
@@ -61,26 +66,27 @@ export const decodeSwiftClassVtables = (input) => {
|
|
|
61
66
|
},
|
|
62
67
|
evidence: read.evidence(entry, "Swift class vtable method descriptor; slot index is a metadata word offset, not a source method ordinal"),
|
|
63
68
|
});
|
|
69
|
+
if (resolved)
|
|
70
|
+
decoded++;
|
|
71
|
+
else
|
|
72
|
+
issues.push(issue("swift_class_vtable_descriptors", "vtable_implementation_unresolved", "Async, coroutine, external or unmapped vtable implementation is unresolved", `0x${entry.toString(16)}`));
|
|
64
73
|
}
|
|
65
|
-
if ((specific & 0x4000) !== 0)
|
|
74
|
+
if ((specific & 0x4000) !== 0) {
|
|
66
75
|
failures.push(`${owner}: inherited override descriptors are unsupported`);
|
|
76
|
+
issues.push(issue("swift_class_vtable_descriptors", "inherited_override_descriptors_unsupported", "Inherited override descriptors are unsupported", `0x${descriptor.toString(16)}`));
|
|
77
|
+
}
|
|
67
78
|
}
|
|
68
79
|
catch (cause) {
|
|
69
|
-
|
|
80
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
81
|
+
failures.push(`0x${field.toString(16)}: ${message}`);
|
|
82
|
+
issues.push(issue("swift_class_vtable_descriptors", "vtable_decode_failed", message, `0x${field.toString(16)}`));
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
|
-
|
|
73
|
-
result.coverage.push({
|
|
85
|
+
return {
|
|
74
86
|
facet: "swift_class_vtable_descriptors",
|
|
75
87
|
examined,
|
|
76
|
-
decoded
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: "complete",
|
|
81
|
-
reason: failures.join("; ") ||
|
|
82
|
-
(slots.some((slot) => slot.decode.status !== "decoded")
|
|
83
|
-
? "vtable_implementations_unresolved"
|
|
84
|
-
: null),
|
|
85
|
-
});
|
|
88
|
+
decoded,
|
|
89
|
+
exhaustive: issues.length === 0,
|
|
90
|
+
issues,
|
|
91
|
+
};
|
|
86
92
|
};
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { createReadStream } from "node:fs";
|
|
3
3
|
import { realpath } from "node:fs/promises";
|
|
4
|
-
import { spawn } from "node:child_process";
|
|
5
4
|
import { err, ok } from "../domain/result.js";
|
|
5
|
+
import { OwnedCommandFailure, runOwnedCommand, } from "../process/OwnedCommand.js";
|
|
6
|
+
/** Maximum wall-clock duration for one native command. */
|
|
7
|
+
export const NATIVE_COMMAND_TIMEOUT_MS = 60_000;
|
|
8
|
+
/** Retain complete command output up to a bounded aggregate size. */
|
|
9
|
+
export const NATIVE_COMMAND_OUTPUT_BUDGET_BYTES = 64 * 1024 * 1024;
|
|
10
|
+
/** Native command failure with retained partial output and cleanup status. */
|
|
6
11
|
export class NativeCommandFailure extends Error {
|
|
7
12
|
tool;
|
|
8
13
|
reason;
|
|
9
14
|
exitCode;
|
|
10
|
-
|
|
15
|
+
capture;
|
|
16
|
+
cleanupFailure;
|
|
17
|
+
cleanupResources;
|
|
18
|
+
constructor(tool, reason, exitCode = null, options, capture = null, cleanupFailure = null, cleanupResources = []) {
|
|
11
19
|
super(`Native command ${tool} failed: ${reason}`, options);
|
|
12
20
|
this.tool = tool;
|
|
13
21
|
this.reason = reason;
|
|
14
22
|
this.exitCode = exitCode;
|
|
23
|
+
this.capture = capture;
|
|
24
|
+
this.cleanupFailure = cleanupFailure;
|
|
25
|
+
this.cleanupResources = cleanupResources;
|
|
15
26
|
}
|
|
16
27
|
}
|
|
17
28
|
/** Run allowlisted Xcode tools directly without a shell. */
|
|
18
29
|
export class XcrunCommandRunner {
|
|
19
30
|
resolveTool;
|
|
20
|
-
#resolved = new Map();
|
|
21
31
|
constructor(resolveTool = (tool, signal) => resolveXcrunTool(tool, signal)) {
|
|
22
32
|
this.resolveTool = resolveTool;
|
|
23
33
|
}
|
|
24
34
|
run(tool, arguments_, options) {
|
|
25
35
|
if (!ALLOWED_TOOLS.has(tool))
|
|
26
36
|
return Promise.resolve(err(new NativeCommandFailure(tool, "unavailable")));
|
|
27
|
-
return this
|
|
37
|
+
return this.resolveTool(tool, options.signal).then(async (resolved) => {
|
|
28
38
|
if (!resolved.ok)
|
|
29
39
|
return resolved;
|
|
30
40
|
const captured = await captureProcess(resolved.value.path, arguments_, tool, options);
|
|
@@ -35,21 +45,12 @@ export class XcrunCommandRunner {
|
|
|
35
45
|
executable: resolved.value.path,
|
|
36
46
|
executableSha256: resolved.value.sha256,
|
|
37
47
|
toolVersion: null,
|
|
38
|
-
versionReason: "Tool exposes no uniform stable version flag; executable
|
|
48
|
+
versionReason: "Tool exposes no uniform stable version flag; executable SHA-256 is a prelaunch file sample and does not prove atomic OS image binding.",
|
|
39
49
|
arguments: [...arguments_],
|
|
40
50
|
})
|
|
41
51
|
: captured;
|
|
42
52
|
});
|
|
43
53
|
}
|
|
44
|
-
async #resolve(tool, signal) {
|
|
45
|
-
const existing = this.#resolved.get(tool);
|
|
46
|
-
if (existing !== undefined)
|
|
47
|
-
return ok(existing);
|
|
48
|
-
const resolved = await this.resolveTool(tool, signal);
|
|
49
|
-
if (resolved.ok)
|
|
50
|
-
this.#resolved.set(tool, resolved.value);
|
|
51
|
-
return resolved;
|
|
52
|
-
}
|
|
53
54
|
}
|
|
54
55
|
const ALLOWED_TOOLS = new Set([
|
|
55
56
|
"codesign",
|
|
@@ -64,93 +65,89 @@ const ALLOWED_TOOLS = new Set([
|
|
|
64
65
|
"swift-demangle",
|
|
65
66
|
"vtool",
|
|
66
67
|
]);
|
|
67
|
-
/** Locate an Xcode tool through `xcrun --find` and
|
|
68
|
+
/** Locate an Xcode tool through `xcrun --find` and sample its executable digest. */
|
|
68
69
|
export const resolveXcrunTool = async (tool, signal) => {
|
|
69
70
|
const found = await captureProcess("/usr/bin/xcrun", ["--find", tool], "xcrun", signal === undefined ? {} : { signal });
|
|
70
71
|
if (!found.ok) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
return err(new NativeCommandFailure(tool, found.error.reason === "nonzero-exit" ||
|
|
73
|
+
found.error.reason === "unavailable"
|
|
74
|
+
? "unavailable"
|
|
75
|
+
: found.error.reason, found.error.exitCode, { cause: found.error }, found.error.capture, found.error.cleanupFailure, found.error.cleanupResources));
|
|
74
76
|
}
|
|
75
77
|
if (found.value.exitCode !== 0)
|
|
76
|
-
return err(new NativeCommandFailure(tool, "unavailable"));
|
|
78
|
+
return err(new NativeCommandFailure(tool, "unavailable", found.value.exitCode, undefined, failureCapture(found.value, false)));
|
|
77
79
|
const candidate = found.value.stdout.trim();
|
|
78
80
|
if (!candidate.startsWith("/"))
|
|
79
|
-
return err(new NativeCommandFailure(tool, "unavailable"));
|
|
81
|
+
return err(new NativeCommandFailure(tool, "unavailable", found.value.exitCode, undefined, failureCapture(found.value, false)));
|
|
80
82
|
try {
|
|
81
83
|
const path = await realpath(candidate);
|
|
82
|
-
return ok({ path, sha256: await hashFile(path) });
|
|
84
|
+
return ok({ path, sha256: await hashFile(path, signal) });
|
|
83
85
|
}
|
|
84
86
|
catch (cause) {
|
|
85
|
-
|
|
87
|
+
const capture = failureCapture(found.value, false);
|
|
88
|
+
if (signal?.aborted === true)
|
|
89
|
+
return err(new NativeCommandFailure(tool, "cancelled", capture.exitCode, { cause }, capture));
|
|
90
|
+
return err(new NativeCommandFailure(tool, "io", capture.exitCode, { cause }, capture));
|
|
86
91
|
}
|
|
87
92
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const failureCapture = (capture, truncated) => ({
|
|
94
|
+
stdout: capture.stdout,
|
|
95
|
+
stderr: capture.stderr,
|
|
96
|
+
stdoutBytes: capture.stdoutBytes,
|
|
97
|
+
stderrBytes: capture.stderrBytes,
|
|
98
|
+
exitCode: capture.exitCode,
|
|
99
|
+
signal: capture.signal,
|
|
100
|
+
truncated,
|
|
101
|
+
});
|
|
102
|
+
const captureProcess = async (executable, arguments_, tool, options) => {
|
|
103
|
+
const runId = `rea-native-command-${randomUUID()}`;
|
|
104
|
+
try {
|
|
105
|
+
const snapshot = await runOwnedCommand({
|
|
106
|
+
command: executable,
|
|
107
|
+
arguments: [...arguments_],
|
|
108
|
+
runId,
|
|
109
|
+
env: {
|
|
110
|
+
PATH: "/usr/bin:/bin:/usr/sbin:/sbin",
|
|
111
|
+
LC_ALL: "C",
|
|
112
|
+
LANG: "C",
|
|
113
|
+
},
|
|
114
|
+
hostEnvironment: {},
|
|
115
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
116
|
+
}, {
|
|
117
|
+
timeoutMs: NATIVE_COMMAND_TIMEOUT_MS,
|
|
118
|
+
diagnosticBytes: NATIVE_COMMAND_OUTPUT_BUDGET_BYTES,
|
|
119
|
+
acceptNonZeroExit: options.acceptNonZero === true,
|
|
120
|
+
});
|
|
121
|
+
return ok(processCaptureFromSnapshot(snapshot));
|
|
92
122
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
REA_NATIVE_RUN_TOKEN: runToken,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
const stdout = [];
|
|
105
|
-
const stderr = [];
|
|
106
|
-
let stdoutBytes = 0;
|
|
107
|
-
let stderrBytes = 0;
|
|
108
|
-
let settled = false;
|
|
109
|
-
let reason;
|
|
110
|
-
const finish = (result) => {
|
|
111
|
-
if (settled)
|
|
112
|
-
return;
|
|
113
|
-
settled = true;
|
|
114
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
115
|
-
resolve(result);
|
|
116
|
-
};
|
|
117
|
-
const stop = (failure) => {
|
|
118
|
-
reason ??= failure;
|
|
119
|
-
child.kill("SIGKILL");
|
|
120
|
-
};
|
|
121
|
-
const onAbort = () => stop("cancelled");
|
|
122
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
123
|
-
child.stdout.on("data", (chunk) => {
|
|
124
|
-
stdoutBytes += chunk.length;
|
|
125
|
-
stdout.push(chunk);
|
|
126
|
-
});
|
|
127
|
-
child.stderr.on("data", (chunk) => {
|
|
128
|
-
stderrBytes += chunk.length;
|
|
129
|
-
stderr.push(chunk);
|
|
130
|
-
});
|
|
131
|
-
child.once("error", (cause) => finish(err(new NativeCommandFailure(tool, "io", null, { cause }))));
|
|
132
|
-
child.once("close", (code, signal) => {
|
|
133
|
-
if (reason !== undefined) {
|
|
134
|
-
finish(err(new NativeCommandFailure(tool, reason, code)));
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (signal !== null || (code !== 0 && options.acceptNonZero !== true)) {
|
|
138
|
-
finish(err(new NativeCommandFailure(tool, "nonzero-exit", code)));
|
|
139
|
-
return;
|
|
123
|
+
catch (cause) {
|
|
124
|
+
if (cause instanceof OwnedCommandFailure) {
|
|
125
|
+
const capture = cause.snapshot === null
|
|
126
|
+
? null
|
|
127
|
+
: failureCapture(processCaptureFromSnapshot(cause.snapshot), cause.snapshot.diagnosticTruncated === true);
|
|
128
|
+
return err(new NativeCommandFailure(tool, cause.reason === "process"
|
|
129
|
+
? processFailureReason(capture)
|
|
130
|
+
: cause.reason, capture?.exitCode ?? null, { cause }, capture, cause.cleanupFailure, cause.resources));
|
|
140
131
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
return err(new NativeCommandFailure(tool, "io", null, { cause }));
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const processFailureReason = (capture) => capture !== null &&
|
|
136
|
+
(capture.signal !== null ||
|
|
137
|
+
(capture.exitCode !== null && capture.exitCode !== 0))
|
|
138
|
+
? "nonzero-exit"
|
|
139
|
+
: "io";
|
|
140
|
+
const processCaptureFromSnapshot = (snapshot) => ({
|
|
141
|
+
stdout: snapshot.stdout.text,
|
|
142
|
+
stderr: snapshot.stderr.text,
|
|
143
|
+
stdoutBytes: snapshot.stdout.bytes,
|
|
144
|
+
stderrBytes: snapshot.stderr.bytes,
|
|
145
|
+
exitCode: snapshot.exitCode ?? null,
|
|
146
|
+
signal: snapshot.signal ?? null,
|
|
150
147
|
});
|
|
151
|
-
const hashFile = (path) => new Promise((resolve, reject) => {
|
|
148
|
+
const hashFile = (path, signal) => new Promise((resolve, reject) => {
|
|
152
149
|
const hash = createHash("sha256");
|
|
153
|
-
const stream = createReadStream(path);
|
|
150
|
+
const stream = createReadStream(path, signal === undefined ? undefined : { signal });
|
|
154
151
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
155
152
|
stream.once("error", reject);
|
|
156
153
|
stream.once("end", () => resolve(hash.digest("hex")));
|