rea-agents 5.0.0 → 6.0.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.
Files changed (275) hide show
  1. package/README.md +157 -650
  2. package/bridge/mitmproxy/capture.py +210 -0
  3. package/bridge/native/rea_lldb_tracer.py +303 -0
  4. package/bridge/process/ProcessRunTokenReader.swift +263 -0
  5. package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
  6. package/bridge/pwndbg/core_context.py +101 -0
  7. package/bridge/pwndbg/launch.py +39 -0
  8. package/bridge/pwndbg/launch_impl.py +34 -0
  9. package/bridge/pwntools/decoder_runtime.py +59 -0
  10. package/bridge/pwntools/layout.py +39 -0
  11. package/bridge/pwntools/layout_impl.py +309 -0
  12. package/bridge/pwntools/recorded_crash.py +39 -0
  13. package/bridge/pwntools/recorded_crash_impl.py +143 -0
  14. package/dist/android/JadxProvider.js +1 -0
  15. package/dist/application/CapabilityInventory.js +21 -0
  16. package/dist/application/DirectAnalysis.js +97 -23
  17. package/dist/application/EvidenceBundleFiles.js +1 -1
  18. package/dist/application/ReconstructionObligationCandidates.js +5 -1
  19. package/dist/application/WebNetworkCapturePort.js +1 -0
  20. package/dist/application/WebNetworkCaptureService.js +132 -0
  21. package/dist/application/WindowsCapabilities.js +1 -1
  22. package/dist/application/binary/AnalysisSnapshotCache.js +49 -6
  23. package/dist/application/binary/BinarySession.js +38 -10
  24. package/dist/application/binary/BinarySessionOpen.js +16 -3
  25. package/dist/application/binary/BinarySessionRecords.js +20 -0
  26. package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
  27. package/dist/application/binaryDiagnostics/BinaryLayoutService.js +57 -0
  28. package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
  29. package/dist/application/binaryDiagnostics/RecordedCrashService.js +60 -0
  30. package/dist/application/evm/EvmInterfacePort.js +1 -0
  31. package/dist/application/evm/EvmInterfaceService.js +62 -0
  32. package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -2
  33. package/dist/application/javascript/JavaScriptApplicationService.js +15 -2
  34. package/dist/application/javascript/JavaScriptArtifactAnalysis.js +42 -23
  35. package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
  36. package/dist/application/javascript/JavaScriptArtifactPathResolution.js +74 -24
  37. package/dist/application/javascript/JavaScriptArtifactReconstruction.js +23 -10
  38. package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
  39. package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +145 -70
  40. package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
  41. package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
  42. package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
  43. package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
  44. package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
  45. package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
  46. package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
  47. package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -5
  48. package/dist/application/{ProcessCli.js → process/ProcessCli.js} +10 -10
  49. package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +4 -4
  50. package/dist/artifacts/ArtifactProvider.js +30 -3
  51. package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
  52. package/dist/artifacts/ZipArtifactReader.js +3 -0
  53. package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
  54. package/dist/artifacts/apple/MachoLoadCommandReader.js +294 -0
  55. package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
  56. package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +3 -3
  57. package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
  58. package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
  59. package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
  60. package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +3 -3
  61. package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
  62. package/dist/artifacts/readStableArtifact.js +20 -4
  63. package/dist/browser/CdpCaptureEventHandlers.js +90 -2
  64. package/dist/browser/CdpCaptureEvents.js +9 -0
  65. package/dist/browser/PlaywrightElectronActiveProvider.js +12 -3
  66. package/dist/browser/history/CaptureFailures.js +101 -0
  67. package/dist/browser/history/CaptureFormatError.js +10 -0
  68. package/dist/browser/history/CaptureRedaction.js +65 -0
  69. package/dist/browser/history/CaptureRelease.js +12 -0
  70. package/dist/browser/history/HarCapture.js +165 -0
  71. package/dist/browser/history/HarCaptureAdapter.js +20 -0
  72. package/dist/browser/history/HarCaptureProcess.js +57 -0
  73. package/dist/browser/history/HarJson.js +91 -0
  74. package/dist/browser/history/HarSchema.js +72 -0
  75. package/dist/browser/history/HistoricalCaptureDecoder.js +186 -0
  76. package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
  77. package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
  78. package/dist/cli/artifactCommands.js +26 -1
  79. package/dist/cli/binaryDiagnosticsCommands.js +39 -0
  80. package/dist/cli/coreAnalysisCommands.js +2 -2
  81. package/dist/cli/coreBinaryCommands.js +8 -8
  82. package/dist/cli/electronCommands.js +16 -9
  83. package/dist/cli/evmCommands.js +24 -0
  84. package/dist/cli/firmwareCommands.js +6 -3
  85. package/dist/cli/javascriptApplicationAnalysis.js +16 -3
  86. package/dist/cli/jsonOutput.js +133 -0
  87. package/dist/cli/nativeCallCommands.js +35 -0
  88. package/dist/cli/processCommands.js +1 -1
  89. package/dist/cli/streamedJsonOutput.js +56 -0
  90. package/dist/cli/utilityCommands.js +2 -0
  91. package/dist/cli/webNetworkCaptureCommands.js +40 -0
  92. package/dist/cli.js +9 -3
  93. package/dist/cliBrowserScenarioCommands.js +2 -2
  94. package/dist/cliCommandNames.js +6 -0
  95. package/dist/cliJsonInput.js +30 -1
  96. package/dist/cliOutput.js +21 -6
  97. package/dist/composition/binaryDiagnostics.js +8 -0
  98. package/dist/composition/evm.js +4 -0
  99. package/dist/composition/webNetworkCaptures.js +6 -0
  100. package/dist/contracts/artifactToolContracts.js +6 -0
  101. package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
  102. package/dist/contracts/browserToolContracts.js +4 -3
  103. package/dist/contracts/errorSchemas.js +8 -1
  104. package/dist/contracts/evm/evmToolContracts.js +20 -0
  105. package/dist/contracts/investigationExamples.js +2 -2
  106. package/dist/contracts/managed/managedToolContracts.js +7 -3
  107. package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
  108. package/dist/contracts/native/nativeToolContracts.js +17 -1
  109. package/dist/contracts/officialToolContracts.js +12 -9
  110. package/dist/contracts/process/processCaptureExample.js +2 -0
  111. package/dist/contracts/sessionLifecycleInputs.js +22 -5
  112. package/dist/contracts/sessionStatusContract.js +10 -2
  113. package/dist/contracts/sessionToolContracts.js +8 -1
  114. package/dist/contracts/sessionToolSchemas.js +10 -3
  115. package/dist/contracts/toolContractExamples.js +1 -1
  116. package/dist/contracts/toolContracts.js +6 -0
  117. package/dist/contracts/toolEffects.js +30 -0
  118. package/dist/contracts/toolOutputSchemaGroups.js +5 -1
  119. package/dist/contracts/toolOutputSchemaPrimitives.js +1 -1
  120. package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
  121. package/dist/domain/analysisErrorBase.js +15 -0
  122. package/dist/domain/analysisErrorCore.js +59 -5
  123. package/dist/domain/analysisErrorPresentation.js +29 -1
  124. package/dist/domain/analysisErrorProjection.js +52 -2
  125. package/dist/domain/analysisSnapshot.js +166 -2
  126. package/dist/domain/apple/dyldPaths.js +81 -0
  127. package/dist/domain/apple/dylibResolution.js +367 -0
  128. package/dist/domain/apple/dylibResolutionFindings.js +75 -0
  129. package/dist/domain/artifactPathSyntax.js +1 -1
  130. package/dist/domain/browserObservation.js +1 -1
  131. package/dist/domain/browserObservationSchemas.js +13 -0
  132. package/dist/domain/browserScenarioValues.js +9 -2
  133. package/dist/domain/callPathSchemas.js +1 -1
  134. package/dist/domain/canonicalDigest.js +13 -1
  135. package/dist/domain/changedBehavior.js +3 -3
  136. package/dist/domain/comparisonStatus.js +2 -30
  137. package/dist/domain/conformanceTrustGate.js +0 -16
  138. package/dist/domain/evidence.js +17 -5
  139. package/dist/domain/evm/evmInterface.js +63 -0
  140. package/dist/domain/explicitSensitiveFailure.js +92 -0
  141. package/dist/domain/explicitSensitiveValues.js +10 -0
  142. package/dist/domain/firmware/firmwareAnalysis.js +8 -1
  143. package/dist/domain/javascript/electronActiveObservation.js +9 -4
  144. package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
  145. package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
  146. package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
  147. package/dist/domain/javascript/javascriptSemanticGraph.js +21 -5
  148. package/dist/domain/jsonValue.js +4 -0
  149. package/dist/domain/localPath.js +2 -0
  150. package/dist/domain/native/binaryLayout.js +357 -0
  151. package/dist/domain/native/nativeCallObservation.js +164 -0
  152. package/dist/domain/native/objcSwiftMetadata.js +0 -39
  153. package/dist/domain/native/recordedCrash.js +266 -0
  154. package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
  155. package/dist/domain/{processCapture.js → process/processCapture.js} +139 -2
  156. package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
  157. package/dist/domain/process/processCaptureParsing.js +54 -0
  158. package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
  159. package/dist/domain/{processComparison.js → process/processComparison.js} +1 -1
  160. package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
  161. package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
  162. package/dist/domain/providerSelectionError.js +4 -2
  163. package/dist/domain/reconstructionVerification.js +3 -3
  164. package/dist/domain/reconstructionVerificationSchemas.js +1 -1
  165. package/dist/domain/residualUnknown.js +3 -2
  166. package/dist/domain/staticRuntimeCorrelation.js +3 -3
  167. package/dist/domain/webCaptureDiff.js +1 -0
  168. package/dist/domain/webNetworkCapture.js +118 -0
  169. package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
  170. package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
  171. package/dist/dotnet/ManagedMemberInspector.js +4 -2
  172. package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
  173. package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
  174. package/dist/dotnet/ManagedMemberRows.js +14 -3
  175. package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
  176. package/dist/dotnet/ManagedMetadataInventory.js +38 -28
  177. package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
  178. package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
  179. package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
  180. package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
  181. package/dist/dotnet/ManagedPeReader.js +11 -0
  182. package/dist/evm/EvmBytecodeCarrier.js +21 -0
  183. package/dist/evm/EvmWorkerLimits.js +40 -0
  184. package/dist/evm/EvmoleFailures.js +126 -0
  185. package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
  186. package/dist/evm/EvmoleInterfaceProvider.js +273 -0
  187. package/dist/evm/EvmoleInterfaceWorker.js +87 -0
  188. package/dist/evm/EvmoleRelease.js +16 -0
  189. package/dist/firmware/FirmwareCommand.js +1 -0
  190. package/dist/generatedPackageMetadata.js +2 -2
  191. package/dist/ghidra/GhidraLauncher.js +1 -0
  192. package/dist/ghidra/GhidraProvider.js +2 -2
  193. package/dist/ghidra/GhidraProviderCapabilities.js +1 -1
  194. package/dist/hopper/BridgeLauncher.js +2 -0
  195. package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
  196. package/dist/javascript/recovery/WakaruCommand.js +3 -0
  197. package/dist/javascript/sourceMaps/SourceMapCommand.js +1 -0
  198. package/dist/native/CommandRunner.js +2 -1
  199. package/dist/native/LldbCallTracer.js +278 -0
  200. package/dist/native/NativeCallObservation.js +135 -0
  201. package/dist/native/NativeMacOSProvider.js +19 -3
  202. package/dist/native/NativeMacOSProviderMetadata.js +8 -3
  203. package/dist/native/pwndbg/PwndbgCoreContext.js +160 -0
  204. package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
  205. package/dist/native/pwntools/PwntoolsFailures.js +180 -0
  206. package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
  207. package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
  208. package/dist/native/pwntools/PwntoolsRelease.js +19 -0
  209. package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
  210. package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
  211. package/dist/native/pwntools/RecordedCrashStructureBindings.js +101 -0
  212. package/dist/process/DarwinProcessRunTokenReader.js +294 -0
  213. package/dist/process/OwnedCommand.js +113 -0
  214. package/dist/process/ProcessOwnership.js +263 -33
  215. package/dist/process/ProcessOwnershipObservation.js +161 -24
  216. package/dist/process/ProviderProcess.js +30 -3
  217. package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
  218. package/dist/{application → process/capture}/ProcessCaptureError.js +17 -1
  219. package/dist/process/capture/ProcessCaptureLifecycle.js +615 -0
  220. package/dist/{application → process/capture}/ProcessHarness.js +195 -29
  221. package/dist/{application → process/capture}/ProcessSampling.js +2 -2
  222. package/dist/server/createServer.js +22 -0
  223. package/dist/server/promptCompletion.js +10 -3
  224. package/dist/server/registerBinaryDiagnosticsTools.js +17 -0
  225. package/dist/server/registerEvidenceTools.js +1 -1
  226. package/dist/server/registerEvmTools.js +17 -0
  227. package/dist/server/registerProcessComparisonTool.js +1 -1
  228. package/dist/server/registerRecordedCrashTools.js +17 -0
  229. package/dist/server/registerSessionTools.js +2 -2
  230. package/dist/server/registerWebNetworkCaptureTool.js +28 -0
  231. package/dist/server/sessionAvailabilityPolicy.js +3 -0
  232. package/dist/server/sessionToolPolicies.js +1 -1
  233. package/dist/server/toolResult.js +1 -1
  234. package/native/windows/build/manifest.json +2 -2
  235. package/native/windows/build/rea-windows-x64.node +0 -0
  236. package/package.json +37 -9
  237. package/scripts/rea.mjs +11 -3
  238. package/skills/reverse-engineer-anything/SKILL.md +23 -3
  239. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
  240. package/third_party/README.md +60 -0
  241. package/third_party/evmole/LICENSE +21 -0
  242. package/third_party/evmole/README.md +22 -0
  243. package/third_party/pwndbg/LICENSE.md +21 -0
  244. package/third_party/pwndbg/README.md +23 -0
  245. package/third_party/pwntools/README.md +40 -0
  246. package/dist/application/AuthorizedArtifactInventory.js +0 -7
  247. package/dist/application/ProcessCaptureLifecycle.js +0 -299
  248. package/dist/application/StoreFileLock.js +0 -124
  249. package/dist/contracts/processCaptureExample.js +0 -2
  250. package/dist/domain/bytecodeProvider.js +0 -178
  251. package/dist/domain/customProtocolCapture.js +0 -137
  252. package/dist/domain/eventProcessTree.js +0 -225
  253. package/dist/domain/mobileApplicationInvestigation.js +0 -159
  254. package/dist/domain/packageAnalysis.js +0 -123
  255. package/dist/domain/peInspection.js +0 -197
  256. package/dist/domain/processCaptureParsing.js +0 -21
  257. package/dist/domain/protocolCapture.js +0 -217
  258. package/dist/domain/runtimeIdentification.js +0 -212
  259. package/dist/generatedMcpToolCatalog.js +0 -37
  260. /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
  261. /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
  262. /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
  263. /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
  264. /package/dist/domain/{processScenario.js → process/processScenario.js} +0 -0
  265. /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
  266. /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
  267. /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
  268. /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
  269. /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
  270. /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
  271. /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
  272. /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
  273. /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
  274. /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
  275. /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
@@ -1,197 +0,0 @@
1
- import { z } from "zod";
2
- /** PE/COFF section characteristics flags. */
3
- export const sectionCharacteristicsSchema = z.object({
4
- /** Section contains executable code. */
5
- has_code: z.boolean().default(false),
6
- /** Section contains initialized data. */
7
- has_initialized_data: z.boolean().default(false),
8
- /** Section contains uninitialized data. */
9
- has_uninitialized_data: z.boolean().default(false),
10
- /** Section can be read. */
11
- readable: z.boolean().default(false),
12
- /** Section can be written. */
13
- writable: z.boolean().default(false),
14
- /** Section can be executed. */
15
- executable: z.boolean().default(false),
16
- });
17
- /** PE/COFF section header. */
18
- export const peSectionSchema = z.strictObject({
19
- name: z.string().min(1),
20
- virtual_size: z.number().int().nonnegative(),
21
- virtual_address: z.number().int().nonnegative(),
22
- raw_size: z.number().int().nonnegative(),
23
- raw_offset: z.number().int().nonnegative(),
24
- characteristics: sectionCharacteristicsSchema,
25
- });
26
- /** PE import entry. */
27
- export const peImportSchema = z.strictObject({
28
- dll: z.string().min(1),
29
- function_name: z.string().min(1),
30
- ordinal: z.number().int().nullable(),
31
- is_delay_import: z.boolean().default(false),
32
- });
33
- /** PE export entry. */
34
- export const peExportSchema = z.strictObject({
35
- name: z.string().min(1),
36
- ordinal: z.number().int().nonnegative(),
37
- rva: z.number().int().nonnegative(),
38
- forwarder: z.string().nullable(),
39
- });
40
- /** PE/COFF resource entry. */
41
- export const peResourceSchema = z.strictObject({
42
- type: z.string().min(1),
43
- name: z.string().nullable(),
44
- language: z.number().int().nullable(),
45
- rva: z.number().int().nonnegative(),
46
- size: z.number().int().nonnegative(),
47
- });
48
- /** PE debug directory entry. */
49
- export const peDebugEntrySchema = z.strictObject({
50
- type: z.string().min(1),
51
- rva: z.number().int().nonnegative(),
52
- size: z.number().int().nonnegative(),
53
- /** PDB GUID if this is a CodeView entry. */
54
- pdb_guid: z.string().nullable(),
55
- /** PDB age if this is a CodeView entry. */
56
- pdb_age: z.number().int().nullable(),
57
- /** PDB path if this is a CodeView entry. */
58
- pdb_path: z.string().nullable(),
59
- });
60
- /** TLS callback entry. */
61
- export const peTlsCallbackSchema = z.strictObject({
62
- callback_rva: z.number().int().nonnegative(),
63
- index: z.number().int().nonnegative(),
64
- });
65
- /** Architecture/machine type. */
66
- export const peMachineTypeSchema = z.enum([
67
- "x86",
68
- "x64",
69
- "arm",
70
- "arm64",
71
- "ia64",
72
- "unknown",
73
- ]);
74
- /** PE/COFF manifest for static inspection. */
75
- export const peManifestSchema = z.strictObject({
76
- /** DOS header magic. */
77
- dos_magic: z.literal(0x5a4d),
78
- /** PE signature. */
79
- pe_signature: z.literal(0x00004550),
80
- /** Machine type. */
81
- machine: peMachineTypeSchema,
82
- /** Number of sections. */
83
- number_of_sections: z.number().int().positive(),
84
- /** Timestamp from the COFF header. */
85
- timestamp: z.number().int().nullable(),
86
- /** PE characteristics flags. */
87
- is_dll: z.boolean().default(false),
88
- is_executable: z.boolean().default(false),
89
- is_console: z.boolean().default(true),
90
- /** Entry point RVA. */
91
- entry_point: z.number().int().nonnegative(),
92
- /** Image base. */
93
- image_base: z.number().int().nonnegative(),
94
- /** Section alignment. */
95
- section_alignment: z.number().int().positive(),
96
- /** Subsystem version. */
97
- subsystem_version: z.string().nullable(),
98
- /** Sections. */
99
- sections: z.array(peSectionSchema),
100
- /** Imports. */
101
- imports: z.array(peImportSchema).default([]),
102
- /** Exports. */
103
- exports: z.array(peExportSchema).default([]),
104
- /** Resources. */
105
- resources: z.array(peResourceSchema).default([]),
106
- /** Debug directory entries. */
107
- debug_entries: z.array(peDebugEntrySchema).default([]),
108
- /** TLS callbacks. */
109
- tls_callbacks: z.array(peTlsCallbackSchema).default([]),
110
- /** Relocations count (not all entries). */
111
- relocations_count: z.number().int().nonnegative().default(0),
112
- /** Image file characteristics. */
113
- image_characteristics: z.array(z.string()).default([]),
114
- });
115
- /** Parse machine type from COFF machine field. */
116
- export function parseMachineType(machine) {
117
- switch (machine) {
118
- case 0x014c:
119
- return "x86";
120
- case 0x8664:
121
- return "x64";
122
- case 0x01c0:
123
- case 0x01c2:
124
- case 0x01c4:
125
- return "arm";
126
- case 0xaa64:
127
- return "arm64";
128
- case 0x0200:
129
- return "ia64";
130
- default:
131
- return "unknown";
132
- }
133
- }
134
- /** Parse section characteristics flags. */
135
- export function parseSectionCharacteristics(characteristics) {
136
- const IMAGE_SCN_CNT_CODE = 0x00000020;
137
- const IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040;
138
- const IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080;
139
- const IMAGE_SCN_MEM_READ = 0x40000000;
140
- const IMAGE_SCN_MEM_WRITE = 0x80000000;
141
- const IMAGE_SCN_MEM_EXECUTE = 0x20000000;
142
- return {
143
- has_code: (characteristics & IMAGE_SCN_CNT_CODE) !== 0,
144
- has_initialized_data: (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) !== 0,
145
- has_uninitialized_data: (characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) !== 0,
146
- readable: (characteristics & IMAGE_SCN_MEM_READ) !== 0,
147
- writable: (characteristics & IMAGE_SCN_MEM_WRITE) !== 0,
148
- executable: (characteristics & IMAGE_SCN_MEM_EXECUTE) !== 0,
149
- };
150
- }
151
- /** Parse image characteristics flags. */
152
- export function parseImageCharacteristics(characteristics) {
153
- const IMAGE_DLL = 0x2000;
154
- const IMAGE_EXECUTABLE = 0x0002;
155
- const IMAGE_CONSOLE = 0x0003;
156
- const flags = [];
157
- if (characteristics & IMAGE_DLL)
158
- flags.push("DLL");
159
- if (characteristics & IMAGE_EXECUTABLE)
160
- flags.push("Executable");
161
- if ((characteristics & 0x0000000f) === IMAGE_CONSOLE)
162
- flags.push("Console");
163
- return flags;
164
- }
165
- /** Parse a PE debug directory type. */
166
- export function parseDebugType(type) {
167
- switch (type) {
168
- case 0:
169
- return "UNKNOWN";
170
- case 1:
171
- return "COFF";
172
- case 2:
173
- return "CODEVIEW";
174
- case 3:
175
- return "POGO";
176
- case 4:
177
- return "MISC";
178
- default:
179
- return "UNKNOWN";
180
- }
181
- }
182
- /** Check if a PE manifest has PDB debug info. */
183
- export function hasPdbInfo(manifest) {
184
- return manifest.debug_entries.some((e) => e.pdb_guid !== null && e.pdb_path !== null);
185
- }
186
- /** Get all imported DLLs from a PE manifest. */
187
- export function getImportedDlls(manifest) {
188
- return [...new Set(manifest.imports.map((i) => i.dll))];
189
- }
190
- /** Get all exported function names from a PE manifest. */
191
- export function getExportedFunctions(manifest) {
192
- return manifest.exports.map((e) => e.name);
193
- }
194
- /** Count executable sections. */
195
- export function countExecutableSections(manifest) {
196
- return manifest.sections.filter((s) => s.characteristics.executable).length;
197
- }
@@ -1,21 +0,0 @@
1
- import { processCaptureSchema, } from "./processCapture.js";
2
- const verifiedCaptures = new WeakSet();
3
- const isVerifiedCapture = (capture) => verifiedCaptures.has(capture);
4
- const attachProof = (capture) => {
5
- verifiedCaptures.add(capture);
6
- if (isVerifiedCapture(capture))
7
- return capture;
8
- throw new TypeError("Process Capture proof ownership failed");
9
- };
10
- /** Parse unknown input and reject invalid commitments or semantics. */
11
- export const parseProcessCapture = (input) => {
12
- const parsed = processCaptureSchema.safeParse(input);
13
- if (parsed.success)
14
- return attachProof(parsed.data);
15
- const issues = parsed.error.issues.flatMap((issue) => issue.code === "custom"
16
- ? [{ path: issue.path.join("."), message: issue.message }]
17
- : []);
18
- if (issues.length > 0)
19
- throw new TypeError(`Invalid process capture: ${issues.map(({ path, message }) => `${path}: ${message}`).join("; ")}`);
20
- throw parsed.error;
21
- };
@@ -1,217 +0,0 @@
1
- import { z } from "zod";
2
- import { jsonValueSchema } from "./jsonValue.js";
3
- /** Supported protocol families for structured protocol capture. */
4
- export const protocolFamilySchema = z.enum([
5
- "grpc",
6
- "protobuf",
7
- "json-rpc",
8
- "messagepack",
9
- ]);
10
- /** A decoded field from a protocol message. */
11
- export const decodedFieldSchema = z.strictObject({
12
- /** Field name or path within the message structure. */
13
- path: z.string().min(1),
14
- /** Wire type or encoding hint. */
15
- wire_type: z.string().nullable(),
16
- /** Decoded field value. */
17
- value: jsonValueSchema.nullable(),
18
- /** Whether this field value was inferred rather than decoded. */
19
- inferred: z.boolean().default(false),
20
- });
21
- /** Schema inference hypothesis for a repeated message pattern. */
22
- export const schemaHypothesisSchema = z.strictObject({
23
- /** Hypothesized field name. */
24
- field_name: z.string().min(1),
25
- /** Inferred type. */
26
- inferred_type: z.string().min(1),
27
- /** Confidence: 0-1 */
28
- confidence: z.number().min(0).max(1),
29
- /** Supporting evidence count. */
30
- evidence_count: z.number().int().nonnegative(),
31
- });
32
- /** Result of decoding a single protocol message. */
33
- export const protocolMessageSchema = z.strictObject({
34
- /** Monotonic sequence number. */
35
- sequence: z.number().int().nonnegative(),
36
- /** Timestamp in milliseconds. */
37
- at_ms: z.number().int().nonnegative(),
38
- /** Protocol family. */
39
- family: protocolFamilySchema,
40
- /** Direction of the message. */
41
- direction: z.enum(["request", "response"]),
42
- /** Transport endpoint or path (e.g. gRPC method path). */
43
- endpoint: z.string().nullable(),
44
- /** Content type of the raw payload. */
45
- content_type: z.string().nullable(),
46
- /** Raw payload bytes as base64. */
47
- raw_payload: z.string().nullable(),
48
- /** Decoded fields from the payload. */
49
- decoded_fields: z.array(decodedFieldSchema).default([]),
50
- /** Inferred schema hypotheses. */
51
- schema_hypotheses: z.array(schemaHypothesisSchema).default([]),
52
- /** Whether decoding was truncated. */
53
- truncated: z.boolean().default(false),
54
- /** Whether the capture producer marked credentials as redacted. */
55
- credentials_redacted: z.boolean().default(false),
56
- });
57
- /** A captured protocol session with messages and inferred schemas. */
58
- export const protocolCaptureSchema = z.strictObject({
59
- /** Protocol family for this capture. */
60
- family: protocolFamilySchema,
61
- /** Captured messages in order. */
62
- messages: z.array(protocolMessageSchema).min(0),
63
- /** Aggregated schema hypotheses across all messages. */
64
- inferred_schema: z.array(schemaHypothesisSchema).default([]),
65
- /** Whether any message was truncated. */
66
- has_truncated: z.boolean().default(false),
67
- /** Whether the capture producer marked credential content as redacted. */
68
- credentials_detected: z.boolean().default(false),
69
- });
70
- /** Classification of a byte sequence as a known protocol family. */
71
- export function classifyProtocolFamily(contentType, path) {
72
- if (contentType) {
73
- if (contentType.includes("application/grpc"))
74
- return "grpc";
75
- if (contentType.includes("application/x-protobuf"))
76
- return "protobuf";
77
- if (contentType.includes("application/json-rpc"))
78
- return "json-rpc";
79
- if (contentType.includes("application/msgpack") ||
80
- contentType.includes("application/x-msgpack"))
81
- return "messagepack";
82
- }
83
- if (path) {
84
- if (path.startsWith("/grpc.") || path.includes("/grpc/"))
85
- return "grpc";
86
- if (path.includes("/json-rpc") || path.includes("/jsonrpc"))
87
- return "json-rpc";
88
- }
89
- return null;
90
- }
91
- /** Decode a JSON-RPC message from raw payload bytes. */
92
- export function decodeJsonRpc(rawPayload) {
93
- const text = new TextDecoder().decode(rawPayload);
94
- const parsed = jsonValueSchema.parse(JSON.parse(text));
95
- const fields = [];
96
- if (typeof parsed === "object" && parsed !== null) {
97
- for (const [key, value] of Object.entries(parsed)) {
98
- fields.push({
99
- path: key,
100
- wire_type: "json",
101
- value,
102
- inferred: false,
103
- });
104
- }
105
- }
106
- return { decoded_fields: fields, truncated: false };
107
- }
108
- /** Decode a MessagePack message (simplified: only checks basic structure). */
109
- export function decodeMessagePack(rawPayload) {
110
- const fields = [];
111
- // MessagePack uses a single-byte type tag
112
- if (rawPayload.length === 0) {
113
- return { decoded_fields: [], truncated: false };
114
- }
115
- const tag = rawPayload[0];
116
- if (tag === undefined)
117
- return { decoded_fields: [], truncated: false };
118
- // Map type: 0x80-0x8f (fixmap), 0xde (map16), 0xdf (map32)
119
- if ((tag >= 0x80 && tag <= 0x8f) || tag === 0xde || tag === 0xdf) {
120
- fields.push({
121
- path: "type",
122
- wire_type: "msgpack",
123
- value: "map",
124
- inferred: false,
125
- });
126
- }
127
- // Array type: 0x90-0x9f (fixarray), 0xdc (array16), 0xdd (array32)
128
- else if ((tag >= 0x90 && tag <= 0x9f) || tag === 0xdc || tag === 0xdd) {
129
- fields.push({
130
- path: "type",
131
- wire_type: "msgpack",
132
- value: "array",
133
- inferred: false,
134
- });
135
- }
136
- else {
137
- fields.push({
138
- path: "type",
139
- wire_type: "msgpack",
140
- value: "unknown",
141
- inferred: true,
142
- });
143
- }
144
- return {
145
- decoded_fields: fields,
146
- truncated: false,
147
- };
148
- }
149
- /** Decode a gRPC frame (5-byte header + protobuf payload). */
150
- export function decodeGrpcFrame(rawPayload) {
151
- // gRPC uses a 5-byte prefix: 1 byte compressed flag + 4 byte length
152
- if (rawPayload.length < 5) {
153
- return {
154
- decoded_fields: [
155
- {
156
- path: "error",
157
- wire_type: "grpc",
158
- value: "frame too short",
159
- inferred: false,
160
- },
161
- ],
162
- truncated: false,
163
- };
164
- }
165
- const compressed = rawPayload[0] !== 0;
166
- const length = ((rawPayload[1] ?? 0) << 24) |
167
- ((rawPayload[2] ?? 0) << 16) |
168
- ((rawPayload[3] ?? 0) << 8) |
169
- (rawPayload[4] ?? 0);
170
- return {
171
- decoded_fields: [
172
- {
173
- path: "compressed",
174
- wire_type: "grpc",
175
- value: compressed,
176
- inferred: false,
177
- },
178
- {
179
- path: "message_length",
180
- wire_type: "grpc",
181
- value: length,
182
- inferred: false,
183
- },
184
- ],
185
- truncated: false,
186
- };
187
- }
188
- /** Infer schema hypotheses from a set of decoded messages. */
189
- export function inferMessageSchema(messages) {
190
- const fieldCounts = new Map();
191
- for (const msg of messages) {
192
- for (const field of msg.decoded_fields) {
193
- const existing = fieldCounts.get(field.path);
194
- if (existing) {
195
- existing.count++;
196
- if (field.wire_type)
197
- existing.types.add(field.wire_type);
198
- }
199
- else {
200
- fieldCounts.set(field.path, {
201
- count: 1,
202
- types: new Set(field.wire_type ?? "unknown"),
203
- });
204
- }
205
- }
206
- }
207
- const hypotheses = [];
208
- for (const [field_name, data] of fieldCounts) {
209
- hypotheses.push({
210
- field_name,
211
- inferred_type: [...data.types].join("|"),
212
- confidence: Math.min(1, data.count / messages.length || 0),
213
- evidence_count: data.count,
214
- });
215
- }
216
- return hypotheses;
217
- }
@@ -1,212 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import canonicalize from "canonicalize";
3
- import { z } from "zod";
4
- import { parseArtifactInventoryEvidence } from "./artifactInventoryEvidence.js";
5
- import { evidenceSchema } from "./evidence.js";
6
- import { digestSchema } from "./../domain/digests.js";
7
- import { prefixedDigestSchema } from "./../domain/digests.js";
8
- const evidenceIdSchema = prefixedDigestSchema("ev");
9
- const runtimeFamilySchema = z.enum([
10
- "android",
11
- "apple",
12
- "javascript",
13
- "jvm",
14
- "native",
15
- "webassembly",
16
- ]);
17
- const observationSchema = z.strictObject({
18
- path: z.string().min(1),
19
- artifact_id: prefixedDigestSchema("art"),
20
- sha256: digestSchema,
21
- format: z.string().min(1),
22
- });
23
- const runtimeObservationShape = {
24
- family: runtimeFamilySchema,
25
- observations: z.array(observationSchema),
26
- };
27
- const identifiedRuntimeSchema = z.discriminatedUnion("inspection", [
28
- z.strictObject({
29
- ...runtimeObservationShape,
30
- inspection: z.literal("available"),
31
- provider_id: z.string().min(1),
32
- reason: z.null(),
33
- }),
34
- z.strictObject({
35
- ...runtimeObservationShape,
36
- inspection: z.literal("provider-missing"),
37
- provider_id: z.null(),
38
- reason: z.string().min(1),
39
- }),
40
- z.strictObject({
41
- ...runtimeObservationShape,
42
- inspection: z.literal("provider-selection-required"),
43
- provider_id: z.null(),
44
- reason: z.string().min(1),
45
- }),
46
- ]);
47
- /** Authenticated artifact inventory pages to classify by runtime family. */
48
- const runtimeIdentificationInputSchema = z.strictObject({
49
- inventory_evidence: z.array(evidenceSchema).min(1),
50
- });
51
- /** Provider-neutral runtime identification with explicit tooling availability. */
52
- export const runtimeIdentificationResultSchema = z.strictObject({
53
- identification_id: prefixedDigestSchema("rid"),
54
- root_sha256: digestSchema,
55
- root_format: z.string().min(1),
56
- source_evidence_ids: z.array(evidenceIdSchema).min(1),
57
- runtimes: z.array(identifiedRuntimeSchema),
58
- coverage: z.strictObject({
59
- status: z.enum(["complete-within-inventory", "partial"]),
60
- inventory_complete: z.boolean(),
61
- }),
62
- limitations: z.array(z.string().min(1)),
63
- });
64
- const PROVIDERS = {
65
- android: {
66
- inspection: "available",
67
- id: "rea-android-application",
68
- reason: null,
69
- },
70
- apple: { inspection: "available", id: "rea-apple-application", reason: null },
71
- javascript: {
72
- inspection: "available",
73
- id: "rea-javascript-application",
74
- reason: null,
75
- },
76
- jvm: {
77
- inspection: "provider-missing",
78
- id: null,
79
- reason: "Install or configure a JVM bytecode-analysis provider.",
80
- },
81
- native: {
82
- inspection: "provider-selection-required",
83
- id: null,
84
- reason: "Select an available native deep-analysis provider for this target and host.",
85
- },
86
- webassembly: {
87
- inspection: "provider-missing",
88
- id: null,
89
- reason: "Install or configure a WebAssembly semantic-analysis provider.",
90
- },
91
- };
92
- /** Identify runtime families without executing or semantically decoding target bytes. */
93
- export const identifyRuntimes = (input) => {
94
- const parsed = runtimeIdentificationInputSchema.parse(input);
95
- const { evidence, inventory } = parseArtifactInventoryEvidence(parsed.inventory_evidence);
96
- const nodes = new Map(inventory.nodes.map((node) => [node.artifact_id, node]));
97
- const grouped = new Map();
98
- const add = (family, observation) => {
99
- const observations = grouped.get(family) ?? [];
100
- observations.push(observation);
101
- grouped.set(family, observations);
102
- };
103
- for (const occurrence of inventory.occurrences) {
104
- if (occurrence.artifact_id === null)
105
- continue;
106
- const node = nodes.get(occurrence.artifact_id);
107
- if (node === undefined)
108
- throw new TypeError("Runtime observation has no artifact node");
109
- const observation = {
110
- path: occurrence.logical_path,
111
- artifact_id: node.artifact_id,
112
- sha256: node.sha256,
113
- format: node.format,
114
- };
115
- for (const family of familiesFor(node.format, occurrence.logical_path))
116
- add(family, observation);
117
- }
118
- const rootObservation = inventory.nodes.find(({ sha256 }) => sha256 === inventory.manifest.root_sha256);
119
- if (rootObservation !== undefined)
120
- for (const family of familiesFor(inventory.manifest.root_format, "."))
121
- add(family, {
122
- path: ".",
123
- artifact_id: rootObservation.artifact_id,
124
- sha256: rootObservation.sha256,
125
- format: rootObservation.format,
126
- });
127
- const runtimes = [...grouped.entries()]
128
- .sort(([left], [right]) => compare(left, right))
129
- .map(([family, values]) => {
130
- const unique = deduplicate(values);
131
- const provider = providerFor(family, inventory.manifest.root_format);
132
- return {
133
- family,
134
- ...runtimeInspection(provider),
135
- observations: unique,
136
- };
137
- });
138
- const limitations = [
139
- ...(!inventory.complete
140
- ? [
141
- "Source inventory pages are incomplete; absent runtimes remain unknown.",
142
- ]
143
- : []),
144
- "Runtime families are identified from exact artifact formats and paths; semantic claims require the named provider.",
145
- ];
146
- const withoutId = {
147
- root_sha256: inventory.manifest.root_sha256,
148
- root_format: inventory.manifest.root_format,
149
- source_evidence_ids: evidence
150
- .map(({ evidence_id: id }) => id)
151
- .sort(compare),
152
- runtimes,
153
- coverage: {
154
- status: inventory.complete
155
- ? "complete-within-inventory"
156
- : "partial",
157
- inventory_complete: inventory.complete,
158
- },
159
- limitations,
160
- };
161
- return runtimeIdentificationResultSchema.parse({
162
- ...withoutId,
163
- identification_id: `rid_${digest(withoutId)}`,
164
- });
165
- };
166
- const providerFor = (family, rootFormat) => family === "android" && rootFormat !== "apk"
167
- ? {
168
- inspection: "provider-selection-required",
169
- id: null,
170
- reason: "Extract or select an APK root before using the Android application provider.",
171
- }
172
- : PROVIDERS[family];
173
- const runtimeInspection = (provider) => provider.inspection === "available"
174
- ? {
175
- inspection: provider.inspection,
176
- provider_id: provider.id,
177
- reason: null,
178
- }
179
- : {
180
- inspection: provider.inspection,
181
- provider_id: null,
182
- reason: provider.reason,
183
- };
184
- const familiesFor = (format, path) => {
185
- const families = new Set();
186
- if (format === "apk" ||
187
- format === "dex" ||
188
- /(?:^|\/)[^/]+\.dex$/iu.test(path) ||
189
- /(?:^|\/)AndroidManifest\.xml$/u.test(path))
190
- families.add("android");
191
- if (format === "ipa")
192
- families.add("apple");
193
- if (format === "javascript-bundle")
194
- families.add("javascript");
195
- if (format === "jvm-class" || /(?:^|\/)[^/]+\.class$/iu.test(path))
196
- families.add("jvm");
197
- if (["elf", "mach-o", "mach-o-universal", "pe", "dos-mz", "dos-com"].includes(format))
198
- families.add("native");
199
- if (format === "webassembly" || /(?:^|\/)[^/]+\.wasm$/iu.test(path))
200
- families.add("webassembly");
201
- return [...families];
202
- };
203
- const deduplicate = (values) => [
204
- ...new Map(values.map((value) => [`${value.path}\0${value.artifact_id}`, value])).values(),
205
- ].sort((left, right) => compare(left.path, right.path));
206
- const compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
207
- const digest = (value) => {
208
- const encoded = canonicalize(value);
209
- if (encoded === undefined)
210
- throw new TypeError("Runtime identification is not canonical JSON");
211
- return createHash("sha256").update(encoded).digest("hex");
212
- };