rea-agents 1.7.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -59
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +42 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +11 -29
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +165 -197
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +112 -0
- package/dist/application/ElectronBoundaryGraph.js +9 -0
- package/dist/application/ElectronBoundaryGraphContext.js +62 -0
- package/dist/application/ElectronBoundaryGraphIpc.js +242 -0
- package/dist/application/ElectronBoundaryGraphNative.js +86 -0
- package/dist/application/ElectronBoundaryGraphWindows.js +223 -0
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +58 -50
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationProviders.js +30 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptApplicationEvidence.js +26 -0
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +89 -0
- package/dist/application/JavaScriptApplicationService.js +74 -0
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +29 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +90 -0
- package/dist/application/JavaScriptArtifactAnalysis.js +52 -7
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +82 -17
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphEvidence.js +24 -14
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +4 -1
- package/dist/application/JavaScriptArtifactReconstructionInput.js +2 -83
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayPlanning.js +201 -0
- package/dist/application/JavaScriptReplayService.js +292 -0
- package/dist/application/JavaScriptRuntimeReconciliationEvidence.js +25 -0
- package/dist/application/JavaScriptRuntimeReconciliationService.js +27 -0
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/ManagedApplicationGraphService.js +55 -0
- package/dist/application/ManagedMemberComparisonService.js +122 -0
- package/dist/application/ManagedNativeVerificationService.js +39 -0
- package/dist/application/ManagedReconstructionService.js +58 -0
- package/dist/application/ManagedRuntimeCorrelationService.js +103 -0
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProcessSampling.js +15 -11
- package/dist/application/ProjectPermissionStore.js +49 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/application/runtime.js +2 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +46 -464
- package/dist/browser/CdpElectronInspection.js +106 -162
- package/dist/browser/CdpElectronProvider.js +5 -1
- package/dist/browser/CdpElectronScriptEvents.js +69 -0
- package/dist/browser/CdpElectronScripts.js +94 -0
- package/dist/browser/CdpElectronWorkers.js +56 -0
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -129
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +8 -1
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +13 -383
- package/dist/cliApplicationCommands.js +176 -0
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +17 -0
- package/dist/cliElectronCommands.js +100 -27
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliJsonInput.js +54 -0
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -292
- package/dist/contracts/applicationToolContracts.js +225 -0
- package/dist/contracts/artifactToolContracts.js +5 -9
- package/dist/contracts/browserToolContracts.js +14 -62
- package/dist/contracts/electronToolContracts.js +45 -19
- package/dist/contracts/errorSchemas.js +1 -0
- package/dist/contracts/investigationExamples.js +0 -6
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +46 -0
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +208 -0
- package/dist/contracts/managedToolContracts.js +153 -0
- package/dist/contracts/managedWorkflowExamples.js +346 -0
- package/dist/contracts/managedWorkflowToolContracts.js +203 -0
- package/dist/contracts/nativeToolContracts.js +2 -6
- package/dist/contracts/promptContracts.js +18 -2
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContractExamples.js +10 -25
- package/dist/contracts/toolContracts.js +49 -47
- package/dist/contracts/toolEffects.js +174 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -535
- package/dist/doctorRuntime.js +42 -1
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +37 -19
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -282
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/bundleComparison.js +4 -4
- package/dist/domain/electronObservation.js +13 -0
- package/dist/domain/electronStaticAnalysis.js +9 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +206 -0
- package/dist/domain/electronStaticAnalysisIpc.js +171 -0
- package/dist/domain/electronStaticAnalysisNative.js +164 -0
- package/dist/domain/electronStaticAnalysisTypes.js +1 -0
- package/dist/domain/electronStaticAnalysisValues.js +103 -0
- package/dist/domain/errors.js +32 -448
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/functionComparisonSchemas.js +3 -8
- package/dist/domain/inputIssueProjection.js +52 -0
- package/dist/domain/javascriptApplicationAnalysis.js +155 -0
- package/dist/domain/javascriptApplicationChangeGraph.js +231 -0
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +18 -0
- package/dist/domain/javascriptApplicationGraph.js +2 -1
- package/dist/domain/javascriptApplicationGraphSchemas.js +7 -0
- package/dist/domain/javascriptApplicationVersionComparison.js +116 -0
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +139 -0
- package/dist/domain/javascriptApplicationVersionItems.js +233 -0
- package/dist/domain/javascriptApplicationVersionKeys.js +170 -0
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureSeed.js +140 -0
- package/dist/domain/javascriptFeatureTrace.js +232 -0
- package/dist/domain/javascriptFeatureTraceSchemas.js +136 -0
- package/dist/domain/javascriptFeatureTraversal.js +100 -0
- package/dist/domain/javascriptNativeHandoff.js +85 -0
- package/dist/domain/javascriptReplay.js +361 -0
- package/dist/domain/javascriptRuntimeLoadState.js +106 -0
- package/dist/domain/javascriptRuntimeReconciliation.js +42 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +169 -0
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +247 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +160 -0
- package/dist/domain/javascriptRuntimeReconciliationResult.js +119 -0
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +316 -0
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +245 -0
- package/dist/domain/javascriptRuntimeStaticCandidates.js +193 -0
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +26 -254
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisFindings.js +39 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +81 -2
- package/dist/domain/javascriptStaticAnalysisState.js +6 -0
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +206 -0
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +452 -0
- package/dist/domain/managedMemberComparison.js +211 -0
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +46 -0
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +196 -0
- package/dist/domain/managedRuntimeCorrelation.js +184 -0
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +9 -3
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +339 -0
- package/dist/dotnet/ManagedMemberInspector.js +153 -0
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataHeaps.js +131 -0
- package/dist/dotnet/ManagedMetadataInventory.js +104 -0
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +259 -0
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +143 -0
- package/dist/dotnet/ManagedPeReader.js +188 -0
- package/dist/dotnet/ManagedReaderFailure.js +10 -0
- package/dist/dotnet/ManagedStaticProvider.js +203 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +67 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -132
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +300 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +217 -0
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/LinuxRuntimeClosure.js +46 -0
- package/dist/replay/LinuxSeccompPolicy.js +40 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/replay/ReplayWorkerProtocol.js +55 -0
- package/dist/replay/SystemJavaScriptReplayHost.js +182 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +158 -41
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +13 -0
- package/dist/server/registerArtifactComparisonTool.js +16 -9
- package/dist/server/registerBrowserTools.js +61 -60
- package/dist/server/registerBundleComparisonTool.js +17 -20
- package/dist/server/registerElectronTools.js +39 -12
- package/dist/server/registerEnhancedTools.js +52 -15
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerEvidenceTools.js +5 -1
- package/dist/server/registerFunctionComparisonTool.js +14 -7
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +103 -132
- package/dist/server/registerManagedTools.js +6 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +13 -0
- package/dist/server/registerOfficialTools.js +81 -67
- package/dist/server/registerProcessComparisonTool.js +25 -47
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +9 -8
- package/dist/server/registerSessionTools.js +77 -216
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/sessionEvidence.js +14 -19
- package/dist/server/toolInputValidation.js +77 -0
- package/dist/server/toolRegistrationOptions.js +177 -2
- package/dist/server/toolResult.js +30 -17
- package/package.json +21 -14
- package/scripts/rea.mjs +1 -1
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +75 -6
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ConfigurationError } from "../domain/errors.js";
|
|
3
|
+
import { err, ok } from "../domain/result.js";
|
|
4
|
+
import {} from "../domain/browserObservation.js";
|
|
5
|
+
import { electronFileRootsSchema } from "../domain/electronObservation.js";
|
|
6
|
+
export const parseStringArray = (encoded, name) => {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = z
|
|
9
|
+
.array(z.string().min(1))
|
|
10
|
+
.max(128)
|
|
11
|
+
.safeParse(JSON.parse(encoded));
|
|
12
|
+
return parsed.success
|
|
13
|
+
? ok(parsed.data)
|
|
14
|
+
: err(new ConfigurationError(parsed.error.issues.some(({ code }) => code === "too_big")
|
|
15
|
+
? `${name} must encode at most 128 strings`
|
|
16
|
+
: `${name} must encode an array of strings`, { cause: parsed.error }));
|
|
17
|
+
}
|
|
18
|
+
catch (cause) {
|
|
19
|
+
return err(new ConfigurationError(`${name} must be valid JSON`, { cause }));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const parseBrowserArray = (encoded, name, itemSchema, maximum) => {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = z
|
|
25
|
+
.array(itemSchema)
|
|
26
|
+
.max(maximum)
|
|
27
|
+
.safeParse(JSON.parse(encoded));
|
|
28
|
+
return parsed.success
|
|
29
|
+
? ok([...new Set(parsed.data)].sort())
|
|
30
|
+
: err(new ConfigurationError(`${name} must encode valid browser scopes`, {
|
|
31
|
+
cause: parsed.error,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
catch (cause) {
|
|
35
|
+
return err(new ConfigurationError(`${name} must be valid JSON`, { cause }));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const parseElectronFileRoots = (encoded) => {
|
|
39
|
+
try {
|
|
40
|
+
const decoded = JSON.parse(encoded);
|
|
41
|
+
if (Array.isArray(decoded) && decoded.length === 0)
|
|
42
|
+
return ok([]);
|
|
43
|
+
const parsed = electronFileRootsSchema.safeParse(decoded);
|
|
44
|
+
return parsed.success
|
|
45
|
+
? ok(parsed.data)
|
|
46
|
+
: err(new ConfigurationError("REA_ELECTRON_FILE_ROOTS_JSON must encode absolute roots", { cause: parsed.error }));
|
|
47
|
+
}
|
|
48
|
+
catch (cause) {
|
|
49
|
+
return err(new ConfigurationError("REA_ELECTRON_FILE_ROOTS_JSON must be valid JSON", { cause }));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const parseLoaderArgs = (encoded) => {
|
|
53
|
+
if (encoded === undefined)
|
|
54
|
+
return ok([]);
|
|
55
|
+
let decoded;
|
|
56
|
+
try {
|
|
57
|
+
decoded = JSON.parse(encoded);
|
|
58
|
+
}
|
|
59
|
+
catch (cause) {
|
|
60
|
+
return err(new ConfigurationError("HOPPER_LOADER_ARGS_JSON must be valid JSON", {
|
|
61
|
+
cause,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
const parsed = z.array(z.string()).safeParse(decoded);
|
|
65
|
+
return parsed.success
|
|
66
|
+
? ok(parsed.data)
|
|
67
|
+
: err(new ConfigurationError("HOPPER_LOADER_ARGS_JSON must encode an array of strings", { cause: parsed.error }));
|
|
68
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isLiteralLoopbackHostname } from "../domain/browserObservation.js";
|
|
2
|
+
export const filePolicy = (roots) => ({
|
|
3
|
+
roots,
|
|
4
|
+
maxBytes: 64 * 1024 * 1024,
|
|
5
|
+
maxDepth: 64,
|
|
6
|
+
maxStringLength: 1024 * 1024,
|
|
7
|
+
maxNodes: 1_000_000,
|
|
8
|
+
});
|
|
9
|
+
export const permissionScope = (capability, roots, options = {}) => ({
|
|
10
|
+
capability,
|
|
11
|
+
roots,
|
|
12
|
+
executables: options.executables ?? [],
|
|
13
|
+
environment_names: options.environment_names ?? [],
|
|
14
|
+
...(options.origins === undefined ? {} : { origins: options.origins }),
|
|
15
|
+
network: options.network ?? "none",
|
|
16
|
+
mount: options.mount ?? false,
|
|
17
|
+
});
|
|
18
|
+
export const administratorGrants = (ceilings) => ceilings.map((ceiling) => ({
|
|
19
|
+
...ceiling,
|
|
20
|
+
grant_id: `administrator:${ceiling.capability}`,
|
|
21
|
+
lifetime: "administrator",
|
|
22
|
+
operation_identity: null,
|
|
23
|
+
expires_at: null,
|
|
24
|
+
}));
|
|
25
|
+
export const browserNetworkScope = (origins) => origins.every((origin) => {
|
|
26
|
+
const hostname = new URL(origin).hostname;
|
|
27
|
+
return isLiteralLoopbackHostname(hostname);
|
|
28
|
+
})
|
|
29
|
+
? "loopback"
|
|
30
|
+
: "external";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/config.js
CHANGED
|
@@ -1,292 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { isAbsolute } from "node:path";
|
|
3
|
-
import { ConfigurationError } from "./domain/errors.js";
|
|
4
|
-
import { err, ok } from "./domain/result.js";
|
|
5
|
-
import { browserEndpointSchema, browserOriginSchema, isLiteralLoopbackHostname, } from "./domain/browserObservation.js";
|
|
6
|
-
import { electronFileRootsSchema } from "./domain/electronObservation.js";
|
|
7
|
-
import { analysisProviderSelectorSchema, } from "./contracts/providerSelection.js";
|
|
8
|
-
const DEFAULT_HOPPER_LAUNCHER_PATH = "/Applications/Hopper Disassembler.app/Contents/MacOS/hopper";
|
|
9
|
-
const defaultHopperLauncherPath = () => process.platform === "linux"
|
|
10
|
-
? "/opt/hopper/bin/Hopper"
|
|
11
|
-
: DEFAULT_HOPPER_LAUNCHER_PATH;
|
|
12
|
-
const environmentSchema = z
|
|
13
|
-
.object({
|
|
14
|
-
REA_ANALYSIS_PROVIDER: analysisProviderSelectorSchema.default("auto"),
|
|
15
|
-
GHIDRA_INSTALL_DIR: z
|
|
16
|
-
.string()
|
|
17
|
-
.min(1)
|
|
18
|
-
.refine(isAbsolute, "GHIDRA_INSTALL_DIR must be absolute")
|
|
19
|
-
.optional(),
|
|
20
|
-
JAVA_HOME: z
|
|
21
|
-
.string()
|
|
22
|
-
.min(1)
|
|
23
|
-
.refine(isAbsolute, "JAVA_HOME must be absolute")
|
|
24
|
-
.optional(),
|
|
25
|
-
HOPPER_LAUNCHER_PATH: z.string().min(1).optional(),
|
|
26
|
-
HOPPER_TARGET_PATH: z.string().min(1).optional(),
|
|
27
|
-
HOPPER_TARGET_KIND: z
|
|
28
|
-
.enum(["executable", "database"])
|
|
29
|
-
.default("executable"),
|
|
30
|
-
HOPPER_LOADER_ARGS_JSON: z.string().optional(),
|
|
31
|
-
REA_LOG_LEVEL: z
|
|
32
|
-
.enum(["trace", "debug", "info", "warn", "error", "fatal", "silent"])
|
|
33
|
-
.default("info"),
|
|
34
|
-
REA_PROCESS_CAPTURE_ENABLED: z.enum(["true", "false"]).default("false"),
|
|
35
|
-
REA_ARTIFACT_NATIVE_MOUNT_ENABLED: z
|
|
36
|
-
.enum(["true", "false"])
|
|
37
|
-
.default("false"),
|
|
38
|
-
REA_ARTIFACT_INTEGRITY_CONTINUE_ENABLED: z
|
|
39
|
-
.enum(["true", "false"])
|
|
40
|
-
.default("false"),
|
|
41
|
-
REA_PROCESS_ALLOW_EXTERNAL_NETWORK: z
|
|
42
|
-
.enum(["true", "false"])
|
|
43
|
-
.default("false"),
|
|
44
|
-
REA_PROCESS_EXECUTABLE_ROOTS_JSON: z.string().default("[]"),
|
|
45
|
-
REA_PROCESS_WORKING_ROOTS_JSON: z.string().default("[]"),
|
|
46
|
-
REA_PROCESS_ALLOWED_ENV_JSON: z.string().default("[]"),
|
|
47
|
-
REA_EVIDENCE_ROOTS_JSON: z.string().default("[]"),
|
|
48
|
-
REA_INVESTIGATION_INPUT_ROOTS_JSON: z.string().default("[]"),
|
|
49
|
-
REA_ANALYSIS_SNAPSHOT_ROOTS_JSON: z.string().default("[]"),
|
|
50
|
-
REA_REFERENCE_ROOTS_JSON: z.string().default("[]"),
|
|
51
|
-
REA_REFERENCE_SECRET_PATTERNS_JSON: z.string().default("[]"),
|
|
52
|
-
REA_BROWSER_OBSERVE_ENABLED: z.enum(["true", "false"]).default("false"),
|
|
53
|
-
REA_BROWSER_CDP_ENDPOINTS_JSON: z.string().default("[]"),
|
|
54
|
-
REA_BROWSER_ALLOWED_ORIGINS_JSON: z.string().default("[]"),
|
|
55
|
-
REA_ELECTRON_OBSERVE_ENABLED: z.enum(["true", "false"]).default("false"),
|
|
56
|
-
REA_ELECTRON_CDP_ENDPOINTS_JSON: z.string().default("[]"),
|
|
57
|
-
REA_ELECTRON_FILE_ROOTS_JSON: z.string().default("[]"),
|
|
58
|
-
REA_PERMISSION_PROJECT_ROOT: z.string().min(1).optional(),
|
|
59
|
-
REA_PERMISSION_PROJECT_STORE: z.string().min(1).optional(),
|
|
60
|
-
})
|
|
61
|
-
.refine((value) => (value.REA_PERMISSION_PROJECT_ROOT === undefined) ===
|
|
62
|
-
(value.REA_PERMISSION_PROJECT_STORE === undefined), {
|
|
63
|
-
message: "REA_PERMISSION_PROJECT_ROOT and REA_PERMISSION_PROJECT_STORE must be configured together",
|
|
64
|
-
});
|
|
65
|
-
const parseStringArray = (encoded, name) => {
|
|
66
|
-
try {
|
|
67
|
-
const parsed = z
|
|
68
|
-
.array(z.string().min(1))
|
|
69
|
-
.max(128)
|
|
70
|
-
.safeParse(JSON.parse(encoded));
|
|
71
|
-
return parsed.success
|
|
72
|
-
? ok(parsed.data)
|
|
73
|
-
: err(new ConfigurationError(parsed.error.issues.some(({ code }) => code === "too_big")
|
|
74
|
-
? `${name} must encode at most 128 strings`
|
|
75
|
-
: `${name} must encode an array of strings`, { cause: parsed.error }));
|
|
76
|
-
}
|
|
77
|
-
catch (cause) {
|
|
78
|
-
return err(new ConfigurationError(`${name} must be valid JSON`, { cause }));
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const parseBrowserArray = (encoded, name, itemSchema, maximum) => {
|
|
82
|
-
try {
|
|
83
|
-
const parsed = z
|
|
84
|
-
.array(itemSchema)
|
|
85
|
-
.max(maximum)
|
|
86
|
-
.safeParse(JSON.parse(encoded));
|
|
87
|
-
return parsed.success
|
|
88
|
-
? ok([...new Set(parsed.data)].sort())
|
|
89
|
-
: err(new ConfigurationError(`${name} must encode valid browser scopes`, {
|
|
90
|
-
cause: parsed.error,
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
catch (cause) {
|
|
94
|
-
return err(new ConfigurationError(`${name} must be valid JSON`, { cause }));
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const parseElectronFileRoots = (encoded) => {
|
|
98
|
-
try {
|
|
99
|
-
const decoded = JSON.parse(encoded);
|
|
100
|
-
if (Array.isArray(decoded) && decoded.length === 0)
|
|
101
|
-
return ok([]);
|
|
102
|
-
const parsed = electronFileRootsSchema.safeParse(decoded);
|
|
103
|
-
return parsed.success
|
|
104
|
-
? ok(parsed.data)
|
|
105
|
-
: err(new ConfigurationError("REA_ELECTRON_FILE_ROOTS_JSON must encode absolute roots", { cause: parsed.error }));
|
|
106
|
-
}
|
|
107
|
-
catch (cause) {
|
|
108
|
-
return err(new ConfigurationError("REA_ELECTRON_FILE_ROOTS_JSON must be valid JSON", { cause }));
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const filePolicy = (roots) => ({
|
|
112
|
-
roots,
|
|
113
|
-
maxBytes: 64 * 1024 * 1024,
|
|
114
|
-
maxDepth: 64,
|
|
115
|
-
maxStringLength: 1024 * 1024,
|
|
116
|
-
maxNodes: 1_000_000,
|
|
117
|
-
});
|
|
118
|
-
const permissionScope = (capability, roots, options = {}) => ({
|
|
119
|
-
capability,
|
|
120
|
-
roots,
|
|
121
|
-
executables: options.executables ?? [],
|
|
122
|
-
environment_names: options.environment_names ?? [],
|
|
123
|
-
...(options.origins === undefined ? {} : { origins: options.origins }),
|
|
124
|
-
network: options.network ?? "none",
|
|
125
|
-
mount: options.mount ?? false,
|
|
126
|
-
});
|
|
127
|
-
const administratorGrants = (ceilings) => ceilings.map((ceiling) => ({
|
|
128
|
-
...ceiling,
|
|
129
|
-
grant_id: `administrator:${ceiling.capability}`,
|
|
130
|
-
lifetime: "administrator",
|
|
131
|
-
operation_identity: null,
|
|
132
|
-
expires_at: null,
|
|
133
|
-
}));
|
|
134
|
-
const parseLoaderArgs = (encoded) => {
|
|
135
|
-
if (encoded === undefined)
|
|
136
|
-
return ok([]);
|
|
137
|
-
let decoded;
|
|
138
|
-
try {
|
|
139
|
-
decoded = JSON.parse(encoded);
|
|
140
|
-
}
|
|
141
|
-
catch (cause) {
|
|
142
|
-
return err(new ConfigurationError("HOPPER_LOADER_ARGS_JSON must be valid JSON", {
|
|
143
|
-
cause,
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
146
|
-
const parsed = z.array(z.string()).safeParse(decoded);
|
|
147
|
-
return parsed.success
|
|
148
|
-
? ok(parsed.data)
|
|
149
|
-
: err(new ConfigurationError("HOPPER_LOADER_ARGS_JSON must encode an array of strings", { cause: parsed.error }));
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Parse provider and authority configuration once at the composition root.
|
|
153
|
-
* Explicit loader arguments override REA's header-derived defaults for a
|
|
154
|
-
* supported target, allowing callers to refine Hopper's loader behavior without
|
|
155
|
-
* bypassing REA's path and executable-header checks.
|
|
156
|
-
*/
|
|
157
|
-
export const parseConfig = (environment) => {
|
|
158
|
-
const parsedEnvironment = environmentSchema.safeParse(environment);
|
|
159
|
-
if (!parsedEnvironment.success) {
|
|
160
|
-
return err(new ConfigurationError("Invalid REA environment configuration", {
|
|
161
|
-
cause: parsedEnvironment.error,
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
const loaderArgs = parseLoaderArgs(parsedEnvironment.data.HOPPER_LOADER_ARGS_JSON);
|
|
165
|
-
if (!loaderArgs.ok)
|
|
166
|
-
return loaderArgs;
|
|
167
|
-
const executableRoots = parseStringArray(parsedEnvironment.data.REA_PROCESS_EXECUTABLE_ROOTS_JSON, "REA_PROCESS_EXECUTABLE_ROOTS_JSON");
|
|
168
|
-
if (!executableRoots.ok)
|
|
169
|
-
return executableRoots;
|
|
170
|
-
const workingRoots = parseStringArray(parsedEnvironment.data.REA_PROCESS_WORKING_ROOTS_JSON, "REA_PROCESS_WORKING_ROOTS_JSON");
|
|
171
|
-
if (!workingRoots.ok)
|
|
172
|
-
return workingRoots;
|
|
173
|
-
const allowedEnvironment = parseStringArray(parsedEnvironment.data.REA_PROCESS_ALLOWED_ENV_JSON, "REA_PROCESS_ALLOWED_ENV_JSON");
|
|
174
|
-
if (!allowedEnvironment.ok)
|
|
175
|
-
return allowedEnvironment;
|
|
176
|
-
const evidenceRoots = parseStringArray(parsedEnvironment.data.REA_EVIDENCE_ROOTS_JSON, "REA_EVIDENCE_ROOTS_JSON");
|
|
177
|
-
if (!evidenceRoots.ok)
|
|
178
|
-
return evidenceRoots;
|
|
179
|
-
const investigationInputRoots = parseStringArray(parsedEnvironment.data.REA_INVESTIGATION_INPUT_ROOTS_JSON, "REA_INVESTIGATION_INPUT_ROOTS_JSON");
|
|
180
|
-
if (!investigationInputRoots.ok)
|
|
181
|
-
return investigationInputRoots;
|
|
182
|
-
const analysisSnapshotRoots = parseStringArray(parsedEnvironment.data.REA_ANALYSIS_SNAPSHOT_ROOTS_JSON, "REA_ANALYSIS_SNAPSHOT_ROOTS_JSON");
|
|
183
|
-
if (!analysisSnapshotRoots.ok)
|
|
184
|
-
return analysisSnapshotRoots;
|
|
185
|
-
const referenceRoots = parseStringArray(parsedEnvironment.data.REA_REFERENCE_ROOTS_JSON, "REA_REFERENCE_ROOTS_JSON");
|
|
186
|
-
if (!referenceRoots.ok)
|
|
187
|
-
return referenceRoots;
|
|
188
|
-
const secretPatterns = parseStringArray(parsedEnvironment.data.REA_REFERENCE_SECRET_PATTERNS_JSON, "REA_REFERENCE_SECRET_PATTERNS_JSON");
|
|
189
|
-
if (!secretPatterns.ok)
|
|
190
|
-
return secretPatterns;
|
|
191
|
-
const browserEndpoints = parseBrowserArray(parsedEnvironment.data.REA_BROWSER_CDP_ENDPOINTS_JSON, "REA_BROWSER_CDP_ENDPOINTS_JSON", browserEndpointSchema, 16);
|
|
192
|
-
if (!browserEndpoints.ok)
|
|
193
|
-
return browserEndpoints;
|
|
194
|
-
const browserOrigins = parseBrowserArray(parsedEnvironment.data.REA_BROWSER_ALLOWED_ORIGINS_JSON, "REA_BROWSER_ALLOWED_ORIGINS_JSON", browserOriginSchema, 32);
|
|
195
|
-
if (!browserOrigins.ok)
|
|
196
|
-
return browserOrigins;
|
|
197
|
-
const electronEndpoints = parseBrowserArray(parsedEnvironment.data.REA_ELECTRON_CDP_ENDPOINTS_JSON, "REA_ELECTRON_CDP_ENDPOINTS_JSON", browserEndpointSchema, 16);
|
|
198
|
-
if (!electronEndpoints.ok)
|
|
199
|
-
return electronEndpoints;
|
|
200
|
-
const electronFileRoots = parseElectronFileRoots(parsedEnvironment.data.REA_ELECTRON_FILE_ROOTS_JSON);
|
|
201
|
-
if (!electronFileRoots.ok)
|
|
202
|
-
return electronFileRoots;
|
|
203
|
-
const permissionCeilings = [
|
|
204
|
-
...(parsedEnvironment.data.REA_PROCESS_CAPTURE_ENABLED === "true"
|
|
205
|
-
? [
|
|
206
|
-
permissionScope("process_capture", workingRoots.value, {
|
|
207
|
-
executables: executableRoots.value,
|
|
208
|
-
environment_names: allowedEnvironment.value,
|
|
209
|
-
network: parsedEnvironment.data.REA_PROCESS_ALLOW_EXTERNAL_NETWORK ===
|
|
210
|
-
"true"
|
|
211
|
-
? "external"
|
|
212
|
-
: "none",
|
|
213
|
-
}),
|
|
214
|
-
]
|
|
215
|
-
: []),
|
|
216
|
-
permissionScope("evidence_read", evidenceRoots.value),
|
|
217
|
-
permissionScope("evidence_write", evidenceRoots.value),
|
|
218
|
-
permissionScope("investigation_input", investigationInputRoots.value),
|
|
219
|
-
permissionScope("investigation_workspace_read", evidenceRoots.value),
|
|
220
|
-
permissionScope("investigation_workspace_write", evidenceRoots.value),
|
|
221
|
-
permissionScope("snapshot_read", analysisSnapshotRoots.value),
|
|
222
|
-
permissionScope("snapshot_write", analysisSnapshotRoots.value),
|
|
223
|
-
permissionScope("artifact_extract", ["/"]),
|
|
224
|
-
permissionScope("reference_read", referenceRoots.value),
|
|
225
|
-
...(parsedEnvironment.data.REA_BROWSER_OBSERVE_ENABLED === "true"
|
|
226
|
-
? [
|
|
227
|
-
permissionScope("browser_observe", [], {
|
|
228
|
-
origins: [...browserEndpoints.value, ...browserOrigins.value],
|
|
229
|
-
network: browserNetworkScope(browserOrigins.value),
|
|
230
|
-
}),
|
|
231
|
-
]
|
|
232
|
-
: []),
|
|
233
|
-
...(parsedEnvironment.data.REA_ELECTRON_OBSERVE_ENABLED === "true"
|
|
234
|
-
? [
|
|
235
|
-
permissionScope("electron_observe", electronFileRoots.value, {
|
|
236
|
-
origins: electronEndpoints.value,
|
|
237
|
-
network: "loopback",
|
|
238
|
-
}),
|
|
239
|
-
]
|
|
240
|
-
: []),
|
|
241
|
-
...(parsedEnvironment.data.REA_ARTIFACT_NATIVE_MOUNT_ENABLED === "true"
|
|
242
|
-
? [permissionScope("native_mount", [], { mount: true })]
|
|
243
|
-
: []),
|
|
244
|
-
];
|
|
245
|
-
return ok({
|
|
246
|
-
analysisProvider: parsedEnvironment.data.REA_ANALYSIS_PROVIDER,
|
|
247
|
-
ghidraInstallDir: parsedEnvironment.data.GHIDRA_INSTALL_DIR,
|
|
248
|
-
ghidraJavaHome: parsedEnvironment.data.JAVA_HOME,
|
|
249
|
-
hopperLauncherPath: parsedEnvironment.data.HOPPER_LAUNCHER_PATH ??
|
|
250
|
-
defaultHopperLauncherPath(),
|
|
251
|
-
hopperTargetPath: parsedEnvironment.data.HOPPER_TARGET_PATH,
|
|
252
|
-
hopperTargetKind: parsedEnvironment.data.HOPPER_TARGET_KIND,
|
|
253
|
-
hopperLoaderArgs: loaderArgs.value,
|
|
254
|
-
logLevel: parsedEnvironment.data.REA_LOG_LEVEL,
|
|
255
|
-
processExecutionPolicy: {
|
|
256
|
-
enabled: parsedEnvironment.data.REA_PROCESS_CAPTURE_ENABLED === "true",
|
|
257
|
-
executableRoots: executableRoots.value,
|
|
258
|
-
workingRoots: workingRoots.value,
|
|
259
|
-
allowedEnvironment: allowedEnvironment.value,
|
|
260
|
-
allowExternalNetwork: parsedEnvironment.data.REA_PROCESS_ALLOW_EXTERNAL_NETWORK === "true",
|
|
261
|
-
},
|
|
262
|
-
artifactNativeMountEnabled: parsedEnvironment.data.REA_ARTIFACT_NATIVE_MOUNT_ENABLED === "true",
|
|
263
|
-
artifactIntegrityContinueEnabled: parsedEnvironment.data.REA_ARTIFACT_INTEGRITY_CONTINUE_ENABLED === "true",
|
|
264
|
-
evidenceFilePolicy: filePolicy(evidenceRoots.value),
|
|
265
|
-
investigationInputRoots: investigationInputRoots.value,
|
|
266
|
-
analysisSnapshotFilePolicy: filePolicy(analysisSnapshotRoots.value),
|
|
267
|
-
referenceSourcePolicy: {
|
|
268
|
-
roots: referenceRoots.value,
|
|
269
|
-
secretPatterns: secretPatterns.value,
|
|
270
|
-
maxBytes: 16 * 1024 * 1024,
|
|
271
|
-
maxEntries: 10_000,
|
|
272
|
-
maxDepth: 32,
|
|
273
|
-
maxPathBytes: 4_096,
|
|
274
|
-
},
|
|
275
|
-
browserObservationEnabled: parsedEnvironment.data.REA_BROWSER_OBSERVE_ENABLED === "true",
|
|
276
|
-
browserCdpEndpoints: browserEndpoints.value,
|
|
277
|
-
browserAllowedOrigins: browserOrigins.value,
|
|
278
|
-
electronObservationEnabled: parsedEnvironment.data.REA_ELECTRON_OBSERVE_ENABLED === "true",
|
|
279
|
-
electronCdpEndpoints: electronEndpoints.value,
|
|
280
|
-
electronFileRoots: electronFileRoots.value,
|
|
281
|
-
permissionCeilings,
|
|
282
|
-
administratorPermissionGrants: administratorGrants(permissionCeilings),
|
|
283
|
-
permissionProjectRoot: parsedEnvironment.data.REA_PERMISSION_PROJECT_ROOT,
|
|
284
|
-
permissionProjectStore: parsedEnvironment.data.REA_PERMISSION_PROJECT_STORE,
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
const browserNetworkScope = (origins) => origins.every((origin) => {
|
|
288
|
-
const hostname = new URL(origin).hostname;
|
|
289
|
-
return isLiteralLoopbackHostname(hostname);
|
|
290
|
-
})
|
|
291
|
-
? "loopback"
|
|
292
|
-
: "external";
|
|
1
|
+
export { parseConfig } from "./config/parseConfig.js";
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { applicationVersionComparisonResultSchema, compareApplicationVersionsInputSchema, } from "../domain/javascriptApplicationVersionComparisonSchemas.js";
|
|
2
|
+
import { applicationFeatureTraceResultSchema, traceApplicationFeatureInputSchema, } from "../domain/javascriptFeatureTraceSchemas.js";
|
|
3
|
+
import { controlledReplayInputSchema, controlledReplayOutputSchema, } from "../domain/javascriptReplay.js";
|
|
4
|
+
import { nodeCharacterizationExecutionInputSchema, nodeCharacterizationExecutionOutputSchema, nodeCharacterizationPreparationInputSchema, nodeCharacterizationPreparationOutputSchema, } from "../domain/nodeRuntimeCharacterization.js";
|
|
5
|
+
import { reconstructionCoverageCommitInputSchema, reconstructionCoverageCommitOutputSchema, reconstructionCoverageQueryInputSchema, } from "../application/ReconstructionCoverageService.js";
|
|
6
|
+
import { reconstructionClosureResultSchema } from "../domain/reconstructionCoverage.js";
|
|
7
|
+
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
|
8
|
+
import { toolContractMetadata } from "./toolEffects.js";
|
|
9
|
+
import { evidenceResultOf } from "./toolOutputSchemas.js";
|
|
10
|
+
import { JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE, JAVASCRIPT_FEATURE_TRACE_EXAMPLE, } from "./javascriptApplicationWorkflowExamples.js";
|
|
11
|
+
const traceOutputSchema = evidenceResultOf(applicationFeatureTraceResultSchema);
|
|
12
|
+
const comparisonOutputSchema = evidenceResultOf(applicationVersionComparisonResultSchema);
|
|
13
|
+
const HASH = "0".repeat(64);
|
|
14
|
+
const NODE_PREPARATION_EXAMPLE = jsonObjectSchema.parse({
|
|
15
|
+
preparation_approved: true,
|
|
16
|
+
selected_alias: "bundle",
|
|
17
|
+
expected_effect: "pure",
|
|
18
|
+
instrumentation: {
|
|
19
|
+
artifact_path: "/approved/bundle.js",
|
|
20
|
+
artifact_sha256: HASH,
|
|
21
|
+
selection: {
|
|
22
|
+
byte_start: 100,
|
|
23
|
+
byte_end: 120,
|
|
24
|
+
selected_sha256: HASH,
|
|
25
|
+
export_name: "selected",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
replay: {
|
|
29
|
+
mode: "plan",
|
|
30
|
+
left: {
|
|
31
|
+
modules: [
|
|
32
|
+
{
|
|
33
|
+
alias: "bundle",
|
|
34
|
+
path: "/approved/bundle.js",
|
|
35
|
+
format: "commonjs-factory",
|
|
36
|
+
role: "module",
|
|
37
|
+
dependencies: {},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
entry_alias: "bundle",
|
|
41
|
+
entry_export: "selected",
|
|
42
|
+
},
|
|
43
|
+
cases: [{ case_id: "empty", arguments: [""] }],
|
|
44
|
+
approved: false,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const COVERAGE_WORKSPACE_EXAMPLE = jsonObjectSchema.parse({
|
|
48
|
+
schema_version: 1,
|
|
49
|
+
workspace_id: `rcw_${HASH}`,
|
|
50
|
+
name: "replacement",
|
|
51
|
+
revision: 1,
|
|
52
|
+
previous_revision_sha256: null,
|
|
53
|
+
revision_sha256: HASH,
|
|
54
|
+
evidence_bundle: {
|
|
55
|
+
bundle_version: 2,
|
|
56
|
+
artifacts: [],
|
|
57
|
+
providers: [],
|
|
58
|
+
environments: [],
|
|
59
|
+
scenarios: [],
|
|
60
|
+
captures: [],
|
|
61
|
+
unknowns: [],
|
|
62
|
+
records: [],
|
|
63
|
+
},
|
|
64
|
+
artifacts: [],
|
|
65
|
+
surfaces: [],
|
|
66
|
+
owners: [],
|
|
67
|
+
claims: [],
|
|
68
|
+
verifier_contracts: [],
|
|
69
|
+
verifier_results: [],
|
|
70
|
+
residual_unknown_ids: [],
|
|
71
|
+
contradictions: [],
|
|
72
|
+
package_proofs: [],
|
|
73
|
+
boundaries: [],
|
|
74
|
+
});
|
|
75
|
+
/** Provider-neutral graph workflow contracts shared by MCP and CLI adapters. */
|
|
76
|
+
export const APPLICATION_TOOL_CONTRACTS = [
|
|
77
|
+
{
|
|
78
|
+
name: "trace_application_feature",
|
|
79
|
+
...toolContractMetadata("trace_application_feature"),
|
|
80
|
+
description: "Trace a typed literal seed through an authenticated JavaScript Application Graph with explicit direction, depth, node, edge, and path bounds. Original static, native, passive-runtime, inferred, and unknown authorities remain distinct; native addon handoffs never open a provider or execute the application.",
|
|
81
|
+
kind: "application",
|
|
82
|
+
inputSchema: traceApplicationFeatureInputSchema,
|
|
83
|
+
outputSchema: traceOutputSchema,
|
|
84
|
+
examples: [
|
|
85
|
+
{
|
|
86
|
+
title: "Trace one module seed through a retained application graph",
|
|
87
|
+
input: JAVASCRIPT_FEATURE_TRACE_EXAMPLE,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "compare_application_versions",
|
|
93
|
+
...toolContractMetadata("compare_application_versions"),
|
|
94
|
+
description: "Compare two authenticated JavaScript Application Graph versions using unique-only exact digest, module source digest, source-map identity, structural fingerprint, and non-module semantic-key tiers. Reports added, removed, changed, ambiguous, and unknown entities plus a bounded changed_from graph without fuzzy or module-ordinal pairing.",
|
|
95
|
+
kind: "application",
|
|
96
|
+
inputSchema: compareApplicationVersionsInputSchema,
|
|
97
|
+
outputSchema: comparisonOutputSchema,
|
|
98
|
+
examples: [
|
|
99
|
+
{
|
|
100
|
+
title: "Compare authenticated static and reconciled application graphs",
|
|
101
|
+
input: JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "run_controlled_replay",
|
|
107
|
+
...toolContractMetadata("run_controlled_replay"),
|
|
108
|
+
description: "Plan or execute a content-bound extracted-module JavaScript replay inside the Linux Bubblewrap, seccomp, and cgroup boundary. Execution requires approved: true and the exact plan digest. Supports deterministic boundary cases and optional left/right differential comparison; observations have controlled-replay authority and do not claim real application runtime behavior.",
|
|
109
|
+
kind: "application",
|
|
110
|
+
inputSchema: controlledReplayInputSchema,
|
|
111
|
+
outputSchema: controlledReplayOutputSchema,
|
|
112
|
+
examples: [
|
|
113
|
+
{
|
|
114
|
+
title: "Plan one extracted ESM parser replay",
|
|
115
|
+
input: {
|
|
116
|
+
mode: "plan",
|
|
117
|
+
left: {
|
|
118
|
+
modules: [
|
|
119
|
+
{
|
|
120
|
+
alias: "parser",
|
|
121
|
+
path: "/approved/parser.mjs",
|
|
122
|
+
format: "esm",
|
|
123
|
+
role: "module",
|
|
124
|
+
dependencies: {},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
entry_alias: "parser",
|
|
128
|
+
entry_export: "default",
|
|
129
|
+
},
|
|
130
|
+
cases: [{ case_id: "empty", arguments: [""] }],
|
|
131
|
+
determinism: {
|
|
132
|
+
clock_iso: "2000-01-01T00:00:00.000Z",
|
|
133
|
+
random_seed: 0,
|
|
134
|
+
locale: "en-US",
|
|
135
|
+
timezone: "UTC",
|
|
136
|
+
platform: "linux",
|
|
137
|
+
},
|
|
138
|
+
limits: {
|
|
139
|
+
wall_time_ms: 3000,
|
|
140
|
+
memory_bytes: 134217728,
|
|
141
|
+
tasks: 8,
|
|
142
|
+
cpu_quota_percent: 50,
|
|
143
|
+
tmpfs_bytes: 16777216,
|
|
144
|
+
module_bytes: 4194304,
|
|
145
|
+
input_bytes: 262144,
|
|
146
|
+
protocol_bytes: 16777216,
|
|
147
|
+
output_bytes: 524288,
|
|
148
|
+
stderr_bytes: 32768,
|
|
149
|
+
result_depth: 16,
|
|
150
|
+
result_nodes: 10000,
|
|
151
|
+
},
|
|
152
|
+
approved: false,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "prepare_node_characterization",
|
|
159
|
+
...toolContractMetadata("prepare_node_characterization"),
|
|
160
|
+
description: "Prepare a hash-bound Node/JavaScript characterization plan and deterministic reversible export transformation without executing target code. The exact source, selected byte range, runtime closure, sandbox profile, cases, and limits are committed for separate execution approval.",
|
|
161
|
+
kind: "application",
|
|
162
|
+
inputSchema: nodeCharacterizationPreparationInputSchema,
|
|
163
|
+
outputSchema: nodeCharacterizationPreparationOutputSchema,
|
|
164
|
+
examples: [
|
|
165
|
+
{
|
|
166
|
+
title: "Prepare one exact bundled callable characterization",
|
|
167
|
+
input: NODE_PREPARATION_EXAMPLE,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "execute_node_characterization",
|
|
173
|
+
...toolContractMetadata("execute_node_characterization"),
|
|
174
|
+
description: "Recompute and execute one separately approved exact Node characterization plan in the owned controlled-replay boundary. Returns transformation, replay, cleanup, and provider-neutral characterization Evidence v2; stale plans fail before execution.",
|
|
175
|
+
kind: "application",
|
|
176
|
+
inputSchema: nodeCharacterizationExecutionInputSchema,
|
|
177
|
+
outputSchema: nodeCharacterizationExecutionOutputSchema,
|
|
178
|
+
examples: [
|
|
179
|
+
{
|
|
180
|
+
title: "Execute one approved exact characterization plan",
|
|
181
|
+
input: {
|
|
182
|
+
execution_approved: true,
|
|
183
|
+
approved_plan_sha256: HASH,
|
|
184
|
+
preparation: NODE_PREPARATION_EXAMPLE,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "commit_reconstruction_coverage",
|
|
191
|
+
...toolContractMetadata("commit_reconstruction_coverage"),
|
|
192
|
+
description: "Atomically commit one canonical evidence-backed reconstruction coverage workspace revision under an approved root. CAS revisions reject lost updates; every Evidence and residual-unknown reference must resolve in the embedded canonical bundle.",
|
|
193
|
+
kind: "application",
|
|
194
|
+
inputSchema: reconstructionCoverageCommitInputSchema,
|
|
195
|
+
outputSchema: reconstructionCoverageCommitOutputSchema,
|
|
196
|
+
examples: [
|
|
197
|
+
{
|
|
198
|
+
title: "Commit the first canonical coverage revision",
|
|
199
|
+
input: {
|
|
200
|
+
approved: true,
|
|
201
|
+
workspace_path: "/approved/coverage.json",
|
|
202
|
+
expected_revision: null,
|
|
203
|
+
workspace: COVERAGE_WORKSPACE_EXAMPLE,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "query_reconstruction_coverage",
|
|
210
|
+
...toolContractMetadata("query_reconstruction_coverage"),
|
|
211
|
+
description: "Evaluate one named reconstruction boundary from a canonical coverage workspace. Missing ownership or inventory is partial; stale, weak, truncated, skipped, or unresolved proof is unknown; contradictions, failed proof, missing owners, and authority routing fail closed.",
|
|
212
|
+
kind: "application",
|
|
213
|
+
inputSchema: reconstructionCoverageQueryInputSchema,
|
|
214
|
+
outputSchema: reconstructionClosureResultSchema,
|
|
215
|
+
examples: [
|
|
216
|
+
{
|
|
217
|
+
title: "Evaluate one replacement boundary",
|
|
218
|
+
input: {
|
|
219
|
+
workspace_path: "/approved/coverage.json",
|
|
220
|
+
boundary_id: "replacement.cli",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { artifactOutputSchemas } from "./toolOutputSchemas.js";
|
|
3
3
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
4
|
+
import { toolContractMetadata } from "./toolEffects.js";
|
|
4
5
|
const pageInput = {
|
|
5
6
|
node_offset: z.number().int().min(0).default(0),
|
|
6
7
|
node_limit: z.number().int().min(1).max(500).default(100),
|
|
@@ -67,22 +68,17 @@ const examples = {
|
|
|
67
68
|
occurrence_ids: [`occ_${"0".repeat(64)}`],
|
|
68
69
|
},
|
|
69
70
|
};
|
|
70
|
-
const artifact = (name, description, inputSchema
|
|
71
|
+
const artifact = (name, description, inputSchema) => {
|
|
71
72
|
const outputSchema = artifactOutputSchemas[name];
|
|
72
73
|
if (outputSchema === undefined)
|
|
73
74
|
throw new Error(`Missing artifact output schema for ${name}`);
|
|
74
75
|
return {
|
|
75
76
|
name,
|
|
77
|
+
...toolContractMetadata(name),
|
|
76
78
|
description,
|
|
77
79
|
kind: "artifact-provider",
|
|
78
80
|
inputSchema,
|
|
79
81
|
outputSchema,
|
|
80
|
-
annotations: {
|
|
81
|
-
readOnlyHint: !mutatesFilesystem,
|
|
82
|
-
destructiveHint: false,
|
|
83
|
-
idempotentHint: true,
|
|
84
|
-
openWorldHint: false,
|
|
85
|
-
},
|
|
86
82
|
examples: [
|
|
87
83
|
{
|
|
88
84
|
title: `Example ${name.replaceAll("_", " ")} request`,
|
|
@@ -93,6 +89,6 @@ const artifact = (name, description, inputSchema, mutatesFilesystem) => {
|
|
|
93
89
|
};
|
|
94
90
|
/** Artifact-graph inventory and explicitly approved safe extraction contracts. */
|
|
95
91
|
export const ARTIFACT_TOOL_CONTRACTS = [
|
|
96
|
-
artifact("inventory_artifact", "Inventory the active application or package as a deterministic, content-addressed artifact graph. Returns bounded node and edge pages without extracting or mounting by default.", artifactInventoryInputSchema
|
|
97
|
-
artifact("extract_artifact", "Extract selected graph artifacts beneath an explicit output root. Requires approval, rejects traversal and symlink escapes, never overwrites, enforces bomb limits, and verifies cleanup.", artifactExtractionInputSchema
|
|
92
|
+
artifact("inventory_artifact", "Inventory the active application or package as a deterministic, content-addressed artifact graph. Returns bounded node and edge pages without extracting or mounting by default.", artifactInventoryInputSchema),
|
|
93
|
+
artifact("extract_artifact", "Extract selected graph artifacts beneath an explicit output root. Requires approval, rejects traversal and symlink escapes, never overwrites, enforces bomb limits, and verifies cleanup.", artifactExtractionInputSchema),
|
|
98
94
|
];
|