rea-agents 6.2.0 → 6.3.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 +18 -20
- package/bridge/hopper_bridge.py +2 -0
- package/dist/android/JadxProvider.js +8 -2
- package/dist/android/JadxSession.js +51 -9
- package/dist/application/BinaryTargetResolver.js +63 -17
- package/dist/application/BrowserScenarioEvidence.js +2 -2
- package/dist/application/ClientConfigurationDocument.js +28 -0
- package/dist/application/ClientRegistrationStatus.js +19 -6
- package/dist/application/DirectAnalysis.js +12 -6
- package/dist/application/DirectAnalysisCleanup.js +0 -1
- package/dist/application/DirectAnalysisStatus.js +2 -5
- package/dist/application/Doctor.js +25 -34
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/InvestigationProviders.js +4 -4
- package/dist/application/JsonFiles.js +15 -15
- package/dist/application/LinuxHopper.js +2 -1
- package/dist/application/ReconstructionObligationCandidates.js +9 -2
- package/dist/application/ReconstructionObligationLedgerProjection.js +3 -1
- package/dist/application/RegularFileRead.js +17 -0
- package/dist/application/Setup.js +18 -7
- package/dist/application/SetupClientConfiguration.js +18 -7
- package/dist/application/SetupHost.js +6 -4
- package/dist/application/SetupPlan.js +19 -15
- package/dist/application/SetupSkill.js +57 -8
- package/dist/application/SupportedClients.js +43 -0
- package/dist/application/Uninstall.js +18 -2
- package/dist/application/UpdateMaintenance.js +6 -2
- package/dist/application/Utf8JsonInput.js +64 -0
- package/dist/application/WebScriptExportService.js +13 -6
- package/dist/application/android/AndroidAnalysisService.js +1 -1
- package/dist/application/binary/AnalysisSnapshotCache.js +5 -4
- package/dist/application/binary/BinarySession.js +16 -0
- package/dist/application/binary/BinarySessionOpen.js +9 -1
- package/dist/application/javascript/ElectronActiveEvidence.js +2 -2
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +5 -1
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +107 -46
- package/dist/application/javascript/JavaScriptApplicationService.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +59 -45
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +0 -6
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +8 -18
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +34 -26
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +44 -12
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +6 -3
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +1 -0
- package/dist/application/javascript/JavaScriptJsonModules.js +2 -2
- package/dist/application/javascript/JavaScriptModuleRelationships.js +5 -17
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +11 -27
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +8 -6
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +7 -5
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphEvidence.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFingerprintProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +4 -4
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +10 -7
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +15 -10
- package/dist/application/native/NativeCallRoutes.js +2 -4
- package/dist/artifacts/ArtifactProvider.js +14 -16
- package/dist/artifacts/ArtifactProviderMetadata.js +1 -4
- package/dist/artifacts/AsarArtifactReader.js +81 -17
- package/dist/artifacts/DirectoryArtifactReader.js +2 -2
- package/dist/artifacts/NativeDmgArtifactReader.js +152 -67
- package/dist/artifacts/NativeDmgOwnership.js +109 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +54 -46
- package/dist/artifacts/apple/MachoLoadCommandReader.js +36 -6
- package/dist/artifacts/extraction/ArtifactExtraction.js +29 -11
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +7 -8
- package/dist/artifacts/inventory/classify.js +33 -14
- package/dist/artifacts/inventory/hashStableRootArtifact.js +37 -0
- package/dist/artifacts/inventory/scanCanonical.js +28 -22
- package/dist/artifacts/inventory/scanReader.js +7 -11
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +65 -27
- package/dist/browser/CdpBrowserProvider.js +4 -3
- package/dist/browser/CdpCaptureStorageFingerprints.js +3 -3
- package/dist/browser/CdpElectronInspection.js +2 -2
- package/dist/browser/CdpElectronProvider.js +4 -3
- package/dist/browser/CdpElectronScripts.js +2 -2
- package/dist/browser/CdpWebMcpDiscovery.js +16 -13
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +6 -6
- package/dist/browser/PlaywrightScenarioBrowser.js +145 -42
- package/dist/browser/PlaywrightScenarioSession.js +3 -11
- package/dist/browser/WebSourceMapFetcher.js +32 -6
- package/dist/browser/assets/ScenarioScriptCapture.js +8 -12
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +13 -9
- package/dist/cli/electronCommands.js +9 -10
- package/dist/cli/javascriptApplicationAnalysis.js +2 -12
- package/dist/cli/jsonOutput.js +3 -2
- package/dist/cli/streamedJsonOutput.js +83 -4
- package/dist/cli/utilityCommands.js +2 -4
- package/dist/cli.js +5 -2
- package/dist/cliJsonFile.js +179 -0
- package/dist/cliJsonInput.js +47 -34
- package/dist/cliObservationOptions.js +4 -0
- package/dist/composition/auxiliaryAnalysisProviders.js +5 -4
- package/dist/composition/browserScenario.js +2 -2
- package/dist/composition/directAnalysis.js +2 -3
- package/dist/contracts/artifactComparisonExample.js +5 -5
- package/dist/contracts/errorSchemas.js +3 -1
- package/dist/contracts/functionComparisonExample.js +8 -0
- package/dist/contracts/inputSchemaPresentation.js +94 -3
- package/dist/contracts/javascript/electronToolContracts.js +2 -1
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +3 -2
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +6 -3
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +8 -7
- package/dist/contracts/managed/managedToolContracts.js +3 -2
- package/dist/contracts/mobileApplicationGraphExamples.js +5 -5
- package/dist/contracts/native/nativeToolContracts.js +1 -1
- package/dist/contracts/sessionLifecycleInputs.js +4 -3
- package/dist/contracts/sessionStatusContract.js +3 -2
- package/dist/contracts/sessionToolContracts.js +3 -2
- package/dist/contracts/sessionToolSchemas.js +3 -2
- package/dist/contracts/toolOutputSchemaGroups.js +2 -2
- package/dist/contracts/toolOutputSchemaPrimitives.js +2 -5
- package/dist/domain/analysisErrorBase.js +5 -0
- package/dist/domain/analysisErrorPresentation.js +4 -2
- package/dist/domain/analysisSnapshot.js +3 -1
- package/dist/domain/analysisView/analysisView.js +1 -3
- package/dist/domain/android/androidPartialObservation.js +36 -0
- package/dist/domain/apple/dylibResolution.js +1 -1
- package/dist/domain/artifactComparison.js +4 -4
- package/dist/domain/artifactGraph.js +1 -1
- package/dist/domain/artifactIdentity.js +8 -8
- package/dist/domain/artifactInspection.js +8 -8
- package/dist/domain/artifactInventoryEvidence.js +5 -5
- package/dist/domain/browserCompleteness.js +3 -2
- package/dist/domain/browserScenarioCaptureValues.js +2 -2
- package/dist/domain/browserScenarioNormalization.js +3 -3
- package/dist/domain/browserScenarioValues.js +3 -2
- package/dist/domain/callPath.js +8 -10
- package/dist/domain/canonicalDigest.js +7 -1
- package/dist/domain/canonicalOrdering.js +1 -13
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/comparisonSemantics.js +0 -5
- package/dist/domain/digests.js +0 -3
- package/dist/domain/evidence.js +10 -5
- package/dist/domain/evidenceBundle.js +51 -33
- package/dist/domain/firmware/firmwareAnalysis.js +4 -3
- package/dist/domain/functionComparison.js +2 -1
- package/dist/domain/functionComparisonNormalization.js +4 -3
- package/dist/domain/functionComparisonResults.js +2 -2
- package/dist/domain/functionDossierEvidence.js +2 -1
- package/dist/domain/hopperValues.js +11 -15
- package/dist/domain/javascript/electronActiveObservation.js +4 -3
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +2 -2
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +9 -1
- package/dist/domain/javascript/electronStaticAnalysisNative.js +5 -3
- package/dist/domain/javascript/electronStaticAnalysisValues.js +8 -4
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +3 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +12 -8
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +4 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +15 -13
- package/dist/domain/javascript/javascriptApplicationVersionComparison.js +4 -4
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +37 -22
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +45 -34
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +7 -7
- package/dist/domain/javascript/javascriptAstFingerprint.js +2 -2
- package/dist/domain/javascript/javascriptAstValues.js +22 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +3 -2
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +31 -23
- package/dist/domain/javascript/javascriptExportShapeSelection.js +2 -2
- package/dist/domain/javascript/javascriptExportShapeVariants.js +3 -2
- package/dist/domain/javascript/javascriptFeatureSeed.js +5 -3
- package/dist/domain/javascript/javascriptFeatureTrace.js +7 -6
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +17 -9
- package/dist/domain/javascript/javascriptFeatureTraversal.js +4 -4
- package/dist/domain/javascript/javascriptNativeHandoff.js +6 -6
- package/dist/domain/javascript/javascriptRuntimeObservation.js +8 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliation.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationActive.js +9 -8
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +212 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +5 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationInputValidation.js +28 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +5 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +12 -223
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +7 -6
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +200 -8
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +9 -7
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +2 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +20 -0
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +7 -9
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +4 -11
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +2 -2
- package/dist/domain/javascript/javascriptSemanticGraph.js +142 -35
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +19 -1
- package/dist/domain/javascript/javascriptSemanticIr.js +0 -4
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +106 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +497 -113
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +190 -0
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +41 -27
- package/dist/domain/javascript/javascriptSemanticObjects.js +2 -6
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +7 -2
- package/dist/domain/javascript/javascriptSemanticProjection.js +20 -14
- package/dist/domain/javascript/javascriptSemanticPromises.js +15 -21
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +23 -0
- package/dist/domain/javascript/javascriptSemanticProvenance.js +3 -3
- package/dist/domain/javascript/javascriptSemanticQuery.js +8 -2
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +3 -2
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -9
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +16 -10
- package/dist/domain/javascript/javascriptSemanticReturns.js +23 -27
- package/dist/domain/javascript/javascriptSemanticTraversal.js +6 -1
- package/dist/domain/javascript/javascriptSemanticValues.js +135 -24
- package/dist/domain/javascript/javascriptSourceMapPaths.js +11 -1
- package/dist/domain/javascript/javascriptSourceParser.js +34 -9
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -6
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +26 -15
- package/dist/domain/javascript/sourceToBundleComparison.js +7 -5
- package/dist/domain/javascript/sourceToBundleSignals.js +7 -7
- package/dist/domain/jsonSerialization.js +109 -55
- package/dist/domain/jsonShape.js +46 -19
- package/dist/domain/localPath.js +10 -4
- package/dist/domain/managed/managedApplicationGraph.js +10 -6
- package/dist/domain/managed/managedApplicationGraphNodes.js +82 -57
- package/dist/domain/managed/managedMemberComparisonMatch.js +6 -7
- package/dist/domain/native/nativeCallObservation.js +2 -4
- package/dist/domain/native/nativeValueFlow.js +5 -11
- package/dist/domain/native/objcSwiftMetadata.js +15 -17
- package/dist/domain/process/processCapture.js +11 -10
- package/dist/domain/process/processCaptureCoverage.js +8 -5
- package/dist/domain/process/processCaptureExample.js +43 -0
- package/dist/domain/process/processCaptureValidation.js +4 -3
- package/dist/domain/process/processComparison.js +0 -23
- package/dist/domain/process/processScenario.js +3 -3
- package/dist/domain/process/processTraceEvaluation.js +4 -4
- package/dist/domain/process/processTraceSpecification.js +1 -3
- package/dist/domain/providerCleanupError.js +6 -2
- package/dist/domain/reconstructionCoverage.js +2 -1
- package/dist/domain/reconstructionUnknowns.js +4 -3
- package/dist/domain/reconstructionVerification.js +3 -2
- package/dist/domain/referenceSourceGraph.js +7 -7
- package/dist/domain/referenceSourceImportParsing.js +34 -45
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +2 -1
- package/dist/domain/swiftSymbolClassification.js +6 -1
- package/dist/domain/symbolAnalysis.js +17 -2
- package/dist/domain/unicodeCodePointOrder.js +6 -0
- package/dist/domain/webBundleAnalyzerInspection.js +9 -1
- package/dist/domain/webCaptureDiff.js +71 -29
- package/dist/domain/webCaptureDiffSchemas.js +2 -8
- package/dist/domain/webInventory.js +3 -2
- package/dist/domain/webMcpDiscovery.js +4 -3
- package/dist/domain/webScriptExport.js +1 -1
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +1 -2
- package/dist/dotnet/ManagedStaticProvider.js +10 -7
- package/dist/dotnet/ManagedStaticProviderMetadata.js +1 -4
- package/dist/filesystem/RegularFile.js +41 -0
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraClient.js +14 -4
- package/dist/ghidra/GhidraInstallation.js +111 -10
- package/dist/ghidra/GhidraLauncher.js +43 -19
- package/dist/hopper/HopperCleanup.js +1 -1
- package/dist/ida/IdaOperationRunner.js +2 -0
- package/dist/ida/IdaSessionClient.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -5
- package/dist/inspector/V8InspectorCaptureProjection.js +46 -13
- package/dist/inspector/V8InspectorProvider.js +60 -8
- package/dist/main/shutdown.js +76 -32
- package/dist/main/transport.js +1 -1
- package/dist/native/AppleObjcDispatchFacets.js +3 -3
- package/dist/native/AppleObjcProperties.js +17 -7
- package/dist/native/LldbCallTracer.js +241 -75
- package/dist/native/NativeMacOSProvider.js +10 -5
- package/dist/native/NativeMacOSProviderMetadata.js +1 -2
- package/dist/process/ProcessOwnershipObservation.js +9 -13
- package/dist/process/capture/FilesystemSnapshot.js +88 -18
- package/dist/process/capture/ProcessCaptureLifecycle.js +13 -27
- package/dist/process/capture/ProcessFilesystemEffects.js +19 -4
- package/dist/process/capture/ProcessHarness.js +8 -21
- package/dist/server/analysisAdmission.js +8 -0
- package/dist/server/createServer.js +22 -23
- package/dist/server/registerApplicationTools/compareExportShapes.js +2 -1
- package/dist/server/registerApplicationTools/helpers.js +3 -2
- package/dist/server/registerArtifactTools.js +2 -2
- package/dist/server/registerCloseLifecycleTool.js +6 -4
- package/dist/server/registerEnhancedTools.js +78 -73
- package/dist/server/registerEvidenceTools.js +54 -46
- package/dist/server/registerManagedTools.js +7 -4
- package/dist/server/registerOfficialTools.js +31 -25
- package/dist/server/registerSessionTools.js +9 -3
- package/native/windows/build/manifest.json +1 -1
- package/package.json +6 -3
- package/skills/reverse-engineer-anything/SKILL.md +5 -5
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +9 -0
- package/dist/artifacts/inventory/policy.js +0 -2
- package/dist/domain/managed/managedApplicationGraphNodeCoverage.js +0 -6
- package/dist/server/registerNativeTools.js +0 -6
|
@@ -1,18 +1,70 @@
|
|
|
1
|
+
import { constants } from "node:buffer";
|
|
1
2
|
import {} from "node:stream";
|
|
2
|
-
import { Filter } from "incur";
|
|
3
|
+
import { Cli, Filter } from "incur";
|
|
3
4
|
import { parseCliOutputArguments } from "../cliOutput.js";
|
|
4
|
-
import {
|
|
5
|
+
import { AnalysisResourceConstraintError } from "../domain/analysisErrorCore.js";
|
|
6
|
+
import { projectAnalysisError, } from "../domain/analysisErrorProjection.js";
|
|
7
|
+
import { jsonOutputParts, writeJsonOutput } from "./jsonOutput.js";
|
|
8
|
+
const registeredCommands = Cli.toCommands;
|
|
9
|
+
/** Install formatting once, after registration, for every ordinary CLI result. */
|
|
10
|
+
export const streamCliCommandResults = (cli, output) => {
|
|
11
|
+
const commands = registeredCommands.get(cli);
|
|
12
|
+
if (commands !== undefined)
|
|
13
|
+
wrapCommands(commands, [], output);
|
|
14
|
+
};
|
|
15
|
+
const wrapCommands = (commands, parents, output) => {
|
|
16
|
+
for (const [name, entry] of commands) {
|
|
17
|
+
const path = [...parents, name];
|
|
18
|
+
if ("_group" in entry) {
|
|
19
|
+
wrapCommands(entry.commands, path, output);
|
|
20
|
+
if (entry.root !== undefined)
|
|
21
|
+
wrapCommand(entry.root, path.join(" "), output);
|
|
22
|
+
}
|
|
23
|
+
else if (!("_alias" in entry) && !("_fetch" in entry))
|
|
24
|
+
wrapCommand(entry, path.join(" "), output);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const wrapCommand = (command, name, output) => {
|
|
28
|
+
const run = command.run;
|
|
29
|
+
command.run = (context) => {
|
|
30
|
+
const started = performance.now();
|
|
31
|
+
const result = run(context);
|
|
32
|
+
// Generator results and Incur's sentinel responses retain their own protocol.
|
|
33
|
+
if (typeof result === "object" &&
|
|
34
|
+
result !== null &&
|
|
35
|
+
Symbol.asyncIterator in result)
|
|
36
|
+
return result;
|
|
37
|
+
return Promise.resolve(result).then(async (value) => {
|
|
38
|
+
if (typeof value === "object" &&
|
|
39
|
+
value !== null &&
|
|
40
|
+
Symbol.for("incur.sentinel") in value)
|
|
41
|
+
return value;
|
|
42
|
+
if (!(await output.write(value, {
|
|
43
|
+
command: name,
|
|
44
|
+
format: context.format,
|
|
45
|
+
duration: `${Math.round(performance.now() - started)}ms`,
|
|
46
|
+
})))
|
|
47
|
+
return value;
|
|
48
|
+
if (output.error !== undefined)
|
|
49
|
+
return context.error({
|
|
50
|
+
code: output.error.code,
|
|
51
|
+
message: output.error.message,
|
|
52
|
+
});
|
|
53
|
+
return undefined;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
};
|
|
5
57
|
/** Preserve Incur's JSON controls while streaming the complete result. */
|
|
6
58
|
export const createStreamedCliJsonOutput = (arguments_, destination) => {
|
|
7
59
|
const options = parseCliOutputArguments(arguments_);
|
|
8
60
|
if (options.parseError ||
|
|
9
|
-
options.tokenCount ||
|
|
10
61
|
options.tokenWindow ||
|
|
11
62
|
(options.format !== "json" && options.format !== "jsonl"))
|
|
12
63
|
return undefined;
|
|
13
64
|
const format = options.format;
|
|
14
65
|
let handled = false;
|
|
15
66
|
let failed = false;
|
|
67
|
+
let error;
|
|
16
68
|
return {
|
|
17
69
|
get handled() {
|
|
18
70
|
return handled;
|
|
@@ -20,6 +72,9 @@ export const createStreamedCliJsonOutput = (arguments_, destination) => {
|
|
|
20
72
|
get failed() {
|
|
21
73
|
return failed;
|
|
22
74
|
},
|
|
75
|
+
get error() {
|
|
76
|
+
return error;
|
|
77
|
+
},
|
|
23
78
|
async write(value, metadata) {
|
|
24
79
|
if (metadata.format !== format)
|
|
25
80
|
return false;
|
|
@@ -30,6 +85,26 @@ export const createStreamedCliJsonOutput = (arguments_, destination) => {
|
|
|
30
85
|
command: metadata.command,
|
|
31
86
|
duration: metadata.duration,
|
|
32
87
|
};
|
|
88
|
+
if (options.tokenCount) {
|
|
89
|
+
// Incur/tokenx materialize the formatted value. Measure its UTF-16
|
|
90
|
+
// expansion before allowing that allocation, independently of UTF-8 bytes.
|
|
91
|
+
let characters = 0;
|
|
92
|
+
if (filtered !== undefined &&
|
|
93
|
+
filtered !== null &&
|
|
94
|
+
typeof filtered !== "function" &&
|
|
95
|
+
typeof filtered !== "symbol")
|
|
96
|
+
for (const part of jsonOutputParts(filtered, format))
|
|
97
|
+
characters += part.length;
|
|
98
|
+
characters = Math.max(0, characters - 1);
|
|
99
|
+
if (characters <= constants.MAX_STRING_LENGTH)
|
|
100
|
+
return false;
|
|
101
|
+
error = projectAnalysisError(new AnalysisResourceConstraintError(metadata.command, "memory", "Token counting requires a formatted string larger than the runtime permits.", {
|
|
102
|
+
formatted_characters: characters,
|
|
103
|
+
max_string_characters: constants.MAX_STRING_LENGTH,
|
|
104
|
+
}, {
|
|
105
|
+
remediationAction: "Remove --token-count to stream the complete JSON result, or narrow it with --filter-output.",
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
33
108
|
const document = options.fullOutput
|
|
34
109
|
? filtered === undefined
|
|
35
110
|
? { ok: true, meta }
|
|
@@ -44,7 +119,11 @@ export const createStreamedCliJsonOutput = (arguments_, destination) => {
|
|
|
44
119
|
// document from Incur's error formatter.
|
|
45
120
|
handled = true;
|
|
46
121
|
try {
|
|
47
|
-
await writeJsonOutput(
|
|
122
|
+
await writeJsonOutput(error === undefined
|
|
123
|
+
? document
|
|
124
|
+
: options.fullOutput
|
|
125
|
+
? { ok: false, error, meta }
|
|
126
|
+
: error, destination, format);
|
|
48
127
|
}
|
|
49
128
|
catch (cause) {
|
|
50
129
|
failed = true;
|
|
@@ -97,7 +97,7 @@ const invalidNativeUiScenarioInput = (operation, issues) => ({
|
|
|
97
97
|
error: "Application workflow failed",
|
|
98
98
|
...projectAnalysisError(new AnalysisInputError(operation, undefined, issues)),
|
|
99
99
|
});
|
|
100
|
-
const registerCapabilityCommands = (cli, logger, {
|
|
100
|
+
const registerCapabilityCommands = (cli, logger, { runSessionStatus }) => {
|
|
101
101
|
for (const command of [
|
|
102
102
|
CLI_COMMANDS.capabilities,
|
|
103
103
|
CLI_COMMANDS.providers,
|
|
@@ -106,9 +106,7 @@ const registerCapabilityCommands = (cli, logger, { runProviderStatus, runCapabil
|
|
|
106
106
|
description: command === "capabilities"
|
|
107
107
|
? "List provider capabilities and side effects"
|
|
108
108
|
: "List configured analysis providers",
|
|
109
|
-
run: () => logCliCommand(logger, command, () =>
|
|
110
|
-
? runProviderStatus(logger)
|
|
111
|
-
: runCapabilityStatus(logger)),
|
|
109
|
+
run: () => logCliCommand(logger, command, () => runSessionStatus(logger)),
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
112
|
};
|
package/dist/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ import { registerElectronCommands } from "./cli/electronCommands.js";
|
|
|
29
29
|
import { registerJavaScriptRuntimeObservationCommands } from "./cliJavaScriptRuntimeCommands.js";
|
|
30
30
|
import { registerApplicationCommands } from "./cli/applicationCommands.js";
|
|
31
31
|
import { presentOmittableDefaults } from "./cli/omittableDefaults.js";
|
|
32
|
+
import { streamCliCommandResults, } from "./cli/streamedJsonOutput.js";
|
|
32
33
|
/**
|
|
33
34
|
* Build the one-shot Incur CLI without starting Hopper at import time.
|
|
34
35
|
* Analysis commands acquire and close their own sessions; bare `mcp` and
|
|
@@ -50,7 +51,7 @@ export const createCli = (selectedEnvironment = process.env, resultOutput) => {
|
|
|
50
51
|
sync: false,
|
|
51
52
|
});
|
|
52
53
|
registerSetupCommands(cli, logger, environment);
|
|
53
|
-
registerCoreAnalysisCommands(cli, logger, analysis.runDirectAnalysis
|
|
54
|
+
registerCoreAnalysisCommands(cli, logger, analysis.runDirectAnalysis);
|
|
54
55
|
registerUtilityCommands(cli, logger, environment, analysis);
|
|
55
56
|
registerEvmCommands(cli, logger, environment);
|
|
56
57
|
registerArtifactCommands(cli, logger, analysis.runProviderAnalysis);
|
|
@@ -70,9 +71,11 @@ export const createCli = (selectedEnvironment = process.env, resultOutput) => {
|
|
|
70
71
|
registerJavaScriptRecoveryCommands(cli, logger, environment);
|
|
71
72
|
registerAdvancedBrowserCommands(cli, logger);
|
|
72
73
|
registerBrowserScenarioCommands(cli, logger, environment);
|
|
73
|
-
registerElectronCommands(cli, logger, environment
|
|
74
|
+
registerElectronCommands(cli, logger, environment);
|
|
74
75
|
registerJavaScriptRuntimeObservationCommands(cli, logger);
|
|
75
76
|
registerApplicationCommands(cli, logger);
|
|
76
77
|
presentOmittableDefaults(cli);
|
|
78
|
+
if (resultOutput !== undefined)
|
|
79
|
+
streamCliCommandResults(cli, resultOutput);
|
|
77
80
|
return cli;
|
|
78
81
|
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { constants } from "node:buffer";
|
|
2
|
+
import { pipeline } from "node:stream/promises";
|
|
3
|
+
import { getHeapStatistics } from "node:v8";
|
|
4
|
+
import parser from "stream-json/parser.js";
|
|
5
|
+
import streamValues from "stream-json/streamers/stream-values.js";
|
|
6
|
+
import { withRegularFile } from "./application/RegularFileRead.js";
|
|
7
|
+
import { JSON_INPUT_RESOURCE_REMEDIATION, parseUtf8Json, } from "./application/Utf8JsonInput.js";
|
|
8
|
+
import { AnalysisInputError, AnalysisResourceConstraintError, } from "./domain/analysisErrorCore.js";
|
|
9
|
+
import { err, ok } from "./domain/result.js";
|
|
10
|
+
const READ_CHUNK_BYTES = 64 * 1024;
|
|
11
|
+
const PACKED_STRING_PART_CODE_UNITS = 64 * 1024;
|
|
12
|
+
// Retain native-parser speed for modest inputs while bounding its extra copies.
|
|
13
|
+
// This selects an implementation; larger files remain accepted through streaming.
|
|
14
|
+
const NATIVE_PARSE_READ_BUDGET = 8 * 1024 * 1024;
|
|
15
|
+
/** Parse strict UTF-8 JSON without requiring a whole-document string. */
|
|
16
|
+
export const readCliJsonFile = (path, operation, signal) => withRegularFile(path, async (handle, stats) => {
|
|
17
|
+
let found = false;
|
|
18
|
+
let value;
|
|
19
|
+
try {
|
|
20
|
+
const prefix = stats.size <= NATIVE_PARSE_READ_BUDGET
|
|
21
|
+
? await readPrefix(handle, stats.size + 1, signal)
|
|
22
|
+
: undefined;
|
|
23
|
+
if (prefix?.complete === true) {
|
|
24
|
+
const parsed = parseUtf8Json(prefix.bytes, operation, path, "cli-json-input");
|
|
25
|
+
return parsed.ok
|
|
26
|
+
? ok(parsed.value)
|
|
27
|
+
: err(invalidJson(operation, parsed.error, parsed.cause));
|
|
28
|
+
}
|
|
29
|
+
await pipeline(decodedChunks(handle, signal, prefix?.bytes), parser.asStream({
|
|
30
|
+
jsonStreaming: false,
|
|
31
|
+
streamValues: false,
|
|
32
|
+
packKeys: false,
|
|
33
|
+
packStrings: false,
|
|
34
|
+
}), packJsonStrings(operation, stats.size), streamValues.asStream(), async (rows) => {
|
|
35
|
+
for await (const row of rows) {
|
|
36
|
+
if (found ||
|
|
37
|
+
typeof row !== "object" ||
|
|
38
|
+
row === null ||
|
|
39
|
+
!("key" in row) ||
|
|
40
|
+
row.key !== 0 ||
|
|
41
|
+
!("value" in row))
|
|
42
|
+
throw new Error("Unexpected JSON parser result");
|
|
43
|
+
found = true;
|
|
44
|
+
value = row.value;
|
|
45
|
+
}
|
|
46
|
+
}, signal === undefined ? {} : { signal });
|
|
47
|
+
return found
|
|
48
|
+
? ok(value)
|
|
49
|
+
: err(invalidJson(operation, "JSON document is empty"));
|
|
50
|
+
}
|
|
51
|
+
catch (cause) {
|
|
52
|
+
if (cause instanceof AnalysisResourceConstraintError)
|
|
53
|
+
return err(cause);
|
|
54
|
+
if (cause instanceof TypeError &&
|
|
55
|
+
"code" in cause &&
|
|
56
|
+
cause.code === "ERR_ENCODING_INVALID_ENCODED_DATA")
|
|
57
|
+
return err(invalidJson(operation, "JSON input is not valid UTF-8", cause));
|
|
58
|
+
if (cause instanceof SyntaxError ||
|
|
59
|
+
(cause instanceof Error && cause.message.startsWith("Parser ")))
|
|
60
|
+
return err(invalidJson(operation, cause.message, cause));
|
|
61
|
+
if (cause instanceof Error &&
|
|
62
|
+
((cause instanceof RangeError &&
|
|
63
|
+
cause.message === "Invalid string length") ||
|
|
64
|
+
("code" in cause && cause.code === "ERR_STRING_TOO_LONG")))
|
|
65
|
+
return err(new AnalysisResourceConstraintError(operation, "memory", "An individual JSON string exceeds the runtime string limit", {
|
|
66
|
+
input_file_bytes: stats.size,
|
|
67
|
+
max_string_code_units: constants.MAX_STRING_LENGTH,
|
|
68
|
+
}, {
|
|
69
|
+
cause,
|
|
70
|
+
remediationAction: JSON_INPUT_RESOURCE_REMEDIATION,
|
|
71
|
+
}));
|
|
72
|
+
throw cause;
|
|
73
|
+
}
|
|
74
|
+
}, signal);
|
|
75
|
+
const packJsonStrings = (operation, inputFileBytes) => async function* (tokens) {
|
|
76
|
+
let kind;
|
|
77
|
+
let length = 0;
|
|
78
|
+
let value = "";
|
|
79
|
+
let parts = [];
|
|
80
|
+
let partLength = 0;
|
|
81
|
+
for await (const token of tokens) {
|
|
82
|
+
if (typeof token !== "object" || token === null || !("name" in token))
|
|
83
|
+
throw new Error("Unexpected JSON parser token");
|
|
84
|
+
switch (token.name) {
|
|
85
|
+
case "startKey":
|
|
86
|
+
case "startString":
|
|
87
|
+
kind = token.name === "startKey" ? "keyValue" : "stringValue";
|
|
88
|
+
break;
|
|
89
|
+
case "stringChunk":
|
|
90
|
+
if (kind === undefined ||
|
|
91
|
+
!("value" in token) ||
|
|
92
|
+
typeof token.value !== "string")
|
|
93
|
+
throw new Error("Unexpected JSON string fragment");
|
|
94
|
+
length += token.value.length;
|
|
95
|
+
if (length > constants.MAX_STRING_LENGTH)
|
|
96
|
+
throw new RangeError("Invalid string length");
|
|
97
|
+
parts.push(token.value);
|
|
98
|
+
partLength += token.value.length;
|
|
99
|
+
if (partLength >= PACKED_STRING_PART_CODE_UNITS) {
|
|
100
|
+
// The tokenizer emits short fragments. Coalesce them before retaining
|
|
101
|
+
// a string so millions of substring/rope nodes cannot exhaust the heap
|
|
102
|
+
// before the native string-length constraint can be reported.
|
|
103
|
+
requireStringAssemblyHeadroom(operation, inputFileBytes, length);
|
|
104
|
+
value += parts.join("");
|
|
105
|
+
parts = [];
|
|
106
|
+
partLength = 0;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case "endKey":
|
|
110
|
+
case "endString":
|
|
111
|
+
if (kind === undefined)
|
|
112
|
+
throw new Error("Unexpected JSON string end");
|
|
113
|
+
requireStringAssemblyHeadroom(operation, inputFileBytes, length);
|
|
114
|
+
yield { name: kind, value: value + parts.join("") };
|
|
115
|
+
kind = undefined;
|
|
116
|
+
length = 0;
|
|
117
|
+
value = "";
|
|
118
|
+
parts = [];
|
|
119
|
+
partLength = 0;
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
yield token;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const requireStringAssemblyHeadroom = (operation, inputFileBytes, stringCodeUnits) => {
|
|
127
|
+
if (stringCodeUnits < PACKED_STRING_PART_CODE_UNITS)
|
|
128
|
+
return;
|
|
129
|
+
const heap = getHeapStatistics();
|
|
130
|
+
// Concatenation or key interning may flatten the retained rope. Reserve its
|
|
131
|
+
// UTF-16 representation and the next coalesced part before that allocation.
|
|
132
|
+
const requiredBytes = 2 * (stringCodeUnits + PACKED_STRING_PART_CODE_UNITS);
|
|
133
|
+
if (requiredBytes > heap.total_available_size)
|
|
134
|
+
throw new AnalysisResourceConstraintError(operation, "memory", "Insufficient heap headroom to assemble a complete JSON string", {
|
|
135
|
+
input_file_bytes: inputFileBytes,
|
|
136
|
+
string_code_units: stringCodeUnits,
|
|
137
|
+
string_assembly_headroom_bytes: requiredBytes,
|
|
138
|
+
available_heap_bytes: heap.total_available_size,
|
|
139
|
+
heap_size_limit_bytes: heap.heap_size_limit,
|
|
140
|
+
}, {
|
|
141
|
+
remediationAction: JSON_INPUT_RESOURCE_REMEDIATION,
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
async function* decodedChunks(handle, signal, prefix) {
|
|
145
|
+
const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
146
|
+
if (prefix !== undefined)
|
|
147
|
+
for (let offset = 0; offset < prefix.length; offset += READ_CHUNK_BYTES) {
|
|
148
|
+
signal?.throwIfAborted();
|
|
149
|
+
yield decoder.decode(prefix.subarray(offset, offset + READ_CHUNK_BYTES), {
|
|
150
|
+
stream: true,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const bytes = Buffer.allocUnsafe(READ_CHUNK_BYTES);
|
|
154
|
+
while (true) {
|
|
155
|
+
signal?.throwIfAborted();
|
|
156
|
+
const read = await handle.read(bytes, 0, bytes.length, null);
|
|
157
|
+
signal?.throwIfAborted();
|
|
158
|
+
if (read.bytesRead === 0)
|
|
159
|
+
break;
|
|
160
|
+
yield decoder.decode(bytes.subarray(0, read.bytesRead), { stream: true });
|
|
161
|
+
}
|
|
162
|
+
yield decoder.decode();
|
|
163
|
+
}
|
|
164
|
+
const readPrefix = async (handle, size, signal) => {
|
|
165
|
+
const bytes = Buffer.allocUnsafe(size);
|
|
166
|
+
let offset = 0;
|
|
167
|
+
while (offset < bytes.length) {
|
|
168
|
+
signal?.throwIfAborted();
|
|
169
|
+
const read = await handle.read(bytes, offset, bytes.length - offset, null);
|
|
170
|
+
signal?.throwIfAborted();
|
|
171
|
+
if (read.bytesRead === 0)
|
|
172
|
+
return { bytes: bytes.subarray(0, offset), complete: true };
|
|
173
|
+
offset += read.bytesRead;
|
|
174
|
+
}
|
|
175
|
+
// The file grew after admission. Continue from this same handle, preserving
|
|
176
|
+
// the prefix already read rather than reopening or dropping its bytes.
|
|
177
|
+
return { bytes, complete: false };
|
|
178
|
+
};
|
|
179
|
+
const invalidJson = (operation, message, cause) => new AnalysisInputError(operation, cause === undefined ? undefined : { cause }, [{ path: [], reason: "invalid_format", expected: "JSON", message }]);
|
package/dist/cliJsonInput.js
CHANGED
|
@@ -1,29 +1,52 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
1
|
import { resolve } from "node:path";
|
|
3
|
-
import {
|
|
2
|
+
import { readCliJsonFile } from "./cliJsonFile.js";
|
|
3
|
+
import { NonRegularFileReadError } from "./filesystem/RegularFile.js";
|
|
4
|
+
import { AnalysisAccessDeniedError, AnalysisInputError, } from "./domain/analysisErrorCore.js";
|
|
4
5
|
import { projectAnalysisError } from "./domain/analysisErrorProjection.js";
|
|
5
6
|
import { safeParseJson } from "./domain/safeJson.js";
|
|
6
7
|
/** Parse inline JSON or one local JSON file for a CLI workflow. */
|
|
7
8
|
export const parseCliJsonInput = async (value, operation) => {
|
|
8
|
-
const inline =
|
|
9
|
-
if (inline
|
|
10
|
-
return { ok: true, value: inline };
|
|
9
|
+
const inline = safeParseJson(value);
|
|
10
|
+
if (inline.ok)
|
|
11
|
+
return { ok: true, value: inline.value };
|
|
11
12
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const parsed = await readCliJsonFile(value, operation);
|
|
14
|
+
return parsed.ok
|
|
15
|
+
? { ok: true, value: parsed.value }
|
|
16
|
+
: {
|
|
17
|
+
ok: false,
|
|
18
|
+
error: {
|
|
19
|
+
error: "Application workflow failed",
|
|
20
|
+
...projectAnalysisError(parsed.error),
|
|
21
|
+
input_path: value,
|
|
22
|
+
input_reason: parsed.error._tag === "AnalysisInputError"
|
|
23
|
+
? "invalid-json"
|
|
24
|
+
: "too-large",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
18
27
|
}
|
|
19
28
|
catch (cause) {
|
|
29
|
+
const systemCode = accessDeniedSystemCode(cause);
|
|
30
|
+
if (systemCode !== undefined)
|
|
31
|
+
return jsonAccessDeniedError(value, operation, systemCode, cause);
|
|
20
32
|
if (["{", "["].includes(value.trimStart()[0] ?? "") &&
|
|
21
33
|
cannotBeAnExistingFile(cause) &&
|
|
22
34
|
!hasExplicitJsonFileExtension(value))
|
|
23
35
|
return { ok: false, error: inputError(operation) };
|
|
36
|
+
if (!(cause instanceof Error) ||
|
|
37
|
+
!("code" in cause) ||
|
|
38
|
+
typeof cause.code !== "string")
|
|
39
|
+
throw cause;
|
|
24
40
|
return jsonFileError(value, operation, "read-failed", cause);
|
|
25
41
|
}
|
|
26
42
|
};
|
|
43
|
+
const accessDeniedSystemCode = (cause) => {
|
|
44
|
+
if (!(cause instanceof Error) || !("code" in cause))
|
|
45
|
+
return undefined;
|
|
46
|
+
return cause.code === "EACCES" || cause.code === "EPERM"
|
|
47
|
+
? cause.code
|
|
48
|
+
: undefined;
|
|
49
|
+
};
|
|
27
50
|
/**
|
|
28
51
|
* Resolve named string fields of CLI-supplied JSON against the operator
|
|
29
52
|
* working directory. Each entry is a key path from the document root; only
|
|
@@ -62,27 +85,6 @@ const cannotBeAnExistingFile = (cause) => typeof cause === "object" &&
|
|
|
62
85
|
cause.code === "ENAMETOOLONG" ||
|
|
63
86
|
cause.code === "ENOTDIR");
|
|
64
87
|
const hasExplicitJsonFileExtension = (value) => value.toLowerCase().endsWith(".json");
|
|
65
|
-
const parseJson = (value) => {
|
|
66
|
-
let text;
|
|
67
|
-
if (typeof value === "string") {
|
|
68
|
-
text = value;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
try {
|
|
72
|
-
text = new TextDecoder("utf-8", {
|
|
73
|
-
fatal: true,
|
|
74
|
-
ignoreBOM: true,
|
|
75
|
-
}).decode(value);
|
|
76
|
-
}
|
|
77
|
-
catch (cause) {
|
|
78
|
-
// Decoding failure means the bytes are not valid UTF-8 JSON input.
|
|
79
|
-
void cause;
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const parsed = safeParseJson(text);
|
|
84
|
-
return parsed.ok ? parsed.value : undefined;
|
|
85
|
-
};
|
|
86
88
|
const inputError = (operation) => ({
|
|
87
89
|
error: "Application workflow failed",
|
|
88
90
|
...projectAnalysisError(new AnalysisInputError(operation, undefined, [
|
|
@@ -100,7 +102,16 @@ const jsonFileError = (path, operation, reason, cause) => ({
|
|
|
100
102
|
input_reason: reason,
|
|
101
103
|
},
|
|
102
104
|
});
|
|
103
|
-
|
|
105
|
+
const jsonAccessDeniedError = (path, operation, systemCode, cause) => ({
|
|
106
|
+
ok: false,
|
|
107
|
+
error: {
|
|
108
|
+
error: "Application workflow failed",
|
|
109
|
+
...projectAnalysisError(new AnalysisAccessDeniedError(operation, path, systemCode, { cause })),
|
|
110
|
+
input_path: path,
|
|
111
|
+
input_reason: "read-failed",
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
/** Preserve file-selection and system failures alongside the requested path. */
|
|
104
115
|
const readFailureIssue = (path, cause) => {
|
|
105
116
|
const code = typeof cause === "object" &&
|
|
106
117
|
cause !== null &&
|
|
@@ -111,6 +122,8 @@ const readFailureIssue = (path, cause) => {
|
|
|
111
122
|
return {
|
|
112
123
|
path: [],
|
|
113
124
|
reason: "invalid_value",
|
|
114
|
-
message:
|
|
125
|
+
message: cause instanceof NonRegularFileReadError && cause.code === "ENOTFILE"
|
|
126
|
+
? `The JSON input must be a regular file${code}: ${path ?? ""}`
|
|
127
|
+
: `The JSON input file could not be read${code}: ${path ?? ""}`,
|
|
115
128
|
};
|
|
116
129
|
};
|
|
@@ -57,4 +57,8 @@ export const javascriptApplicationOptions = z.object({
|
|
|
57
57
|
.enum(["auto", "asar", "directory"])
|
|
58
58
|
.default("auto")
|
|
59
59
|
.describe("Application artifact format"),
|
|
60
|
+
integrityPolicy: z
|
|
61
|
+
.enum(["fail", "record-and-continue"])
|
|
62
|
+
.default("fail")
|
|
63
|
+
.describe("Behavior when declared application integrity does not match"),
|
|
60
64
|
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { artifactCapabilities } from "../artifacts/ArtifactProviderMetadata.js";
|
|
3
|
+
import { ARTIFACT_GRAPH_PROVIDER, MANAGED_STATIC_PROVIDER, } from "../application/InvestigationProviders.js";
|
|
4
|
+
import { managedStaticCapabilities } from "../dotnet/ManagedStaticProviderMetadata.js";
|
|
4
5
|
import { NATIVE_MACOS_PROVIDER_IDENTITY, nativeMacOSCapabilities, } from "../native/NativeMacOSProviderMetadata.js";
|
|
5
6
|
/** Wire the three existing auxiliary AnalysisProvider implementations lazily. */
|
|
6
7
|
export const auxiliaryAnalysisProviderDeclarations = (selectedEnvironment, platform = process.platform) => {
|
|
7
8
|
const environment = snapshotEnvironment(selectedEnvironment, platform);
|
|
8
9
|
return [
|
|
9
10
|
{
|
|
10
|
-
identity:
|
|
11
|
+
identity: ARTIFACT_GRAPH_PROVIDER,
|
|
11
12
|
capabilities: artifactCapabilities(platform),
|
|
12
13
|
load: async () => {
|
|
13
14
|
const { ArtifactProvider } = await import("../artifacts/ArtifactProvider.js");
|
|
@@ -23,7 +24,7 @@ export const auxiliaryAnalysisProviderDeclarations = (selectedEnvironment, platf
|
|
|
23
24
|
},
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
|
-
identity:
|
|
27
|
+
identity: MANAGED_STATIC_PROVIDER,
|
|
27
28
|
capabilities: managedStaticCapabilities(),
|
|
28
29
|
load: async () => {
|
|
29
30
|
const { ManagedStaticProvider } = await import("../dotnet/ManagedStaticProvider.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PlaywrightBrowserScenarioProvider } from "../browser/PlaywrightBrowserScenarioProvider.js";
|
|
2
|
-
import {
|
|
2
|
+
import { PlaywrightScenarioSession } from "../browser/PlaywrightScenarioSession.js";
|
|
3
3
|
/** Construct a fresh provider without opening a target or acquiring an engine. */
|
|
4
|
-
export const createBrowserScenarioProvider = (environment) => new PlaywrightBrowserScenarioProvider(
|
|
4
|
+
export const createBrowserScenarioProvider = (environment) => new PlaywrightBrowserScenarioProvider((scenario, options) => PlaywrightScenarioSession.open(scenario, environment, options));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
|
2
2
|
import { parseConfig } from "../config/parseConfig.js";
|
|
3
3
|
import { runDirectAnalysis as executeDirectAnalysis, runProviderAnalysis as executeProviderAnalysis, runManagedProviderExecution as executeManagedProvider, } from "../application/DirectAnalysis.js";
|
|
4
|
-
import {
|
|
4
|
+
import { runSessionStatus as executeSessionStatus } from "../application/DirectAnalysisStatus.js";
|
|
5
5
|
import { createBinarySession, createManagedBinarySession } from "./binary.js";
|
|
6
6
|
/** Bind one-shot analysis and status commands to one caller-selected environment. */
|
|
7
7
|
export const createDirectAnalysis = (selectedEnvironment) => {
|
|
@@ -14,8 +14,7 @@ export const createDirectAnalysis = (selectedEnvironment) => {
|
|
|
14
14
|
return {
|
|
15
15
|
runDirectAnalysis: executeDirectAnalysis.bind(undefined, dependencies),
|
|
16
16
|
runProviderAnalysis: executeProviderAnalysis.bind(undefined, dependencies),
|
|
17
|
-
|
|
18
|
-
runCapabilityStatus: executeCapabilityStatus.bind(undefined, dependencies),
|
|
17
|
+
runSessionStatus: executeSessionStatus.bind(undefined, dependencies),
|
|
19
18
|
};
|
|
20
19
|
};
|
|
21
20
|
/** Execute managed metadata without configuration or native provider candidates. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { digestCanonicalValue } from "../domain/canonicalDigest.js";
|
|
2
2
|
import { createEvidence } from "../domain/evidence.js";
|
|
3
3
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
4
4
|
const inventory = (digit) => {
|
|
5
5
|
const sha = digit.repeat(64);
|
|
6
|
-
const artifactId = `art_${
|
|
7
|
-
const occurrenceId = `occ_${
|
|
6
|
+
const artifactId = `art_${digestCanonicalValue({ sha256: sha }, "Artifact example")}`;
|
|
7
|
+
const occurrenceId = `occ_${digestCanonicalValue({ root: artifactId }, "Artifact example")}`;
|
|
8
8
|
const nodes = [
|
|
9
9
|
{
|
|
10
10
|
artifact_id: artifactId,
|
|
@@ -35,7 +35,7 @@ const inventory = (digit) => {
|
|
|
35
35
|
limitations: [],
|
|
36
36
|
},
|
|
37
37
|
];
|
|
38
|
-
const graphSha256 =
|
|
38
|
+
const graphSha256 = digestCanonicalValue({
|
|
39
39
|
nodes,
|
|
40
40
|
occurrences,
|
|
41
41
|
edges: [],
|
|
@@ -43,7 +43,7 @@ const inventory = (digit) => {
|
|
|
43
43
|
}, "Artifact example");
|
|
44
44
|
return jsonValueSchema.parse({
|
|
45
45
|
manifest: {
|
|
46
|
-
manifest_id: `agm_${
|
|
46
|
+
manifest_id: `agm_${digestCanonicalValue({
|
|
47
47
|
root_artifact_id: artifactId,
|
|
48
48
|
graph_sha256: graphSha256,
|
|
49
49
|
}, "Artifact example")}`,
|
|
@@ -68,7 +68,9 @@ export const analysisCliErrorEnvelopeSchema = z
|
|
|
68
68
|
.object({
|
|
69
69
|
error: z.string().min(1),
|
|
70
70
|
input_path: z.string().optional(),
|
|
71
|
-
input_reason: z
|
|
71
|
+
input_reason: z
|
|
72
|
+
.enum(["invalid-json", "read-failed", "too-large"])
|
|
73
|
+
.optional(),
|
|
72
74
|
})
|
|
73
75
|
.passthrough()
|
|
74
76
|
.superRefine((value, context) => {
|
|
@@ -5,6 +5,11 @@ const dossier = (text) => jsonValueSchema.parse({
|
|
|
5
5
|
procedure: {
|
|
6
6
|
address: "0x1000",
|
|
7
7
|
name: "main",
|
|
8
|
+
classification: null,
|
|
9
|
+
body: {
|
|
10
|
+
available: false,
|
|
11
|
+
reason: "The fixture omits function-body extent observations.",
|
|
12
|
+
},
|
|
8
13
|
signature: "int main(void)",
|
|
9
14
|
locals: [],
|
|
10
15
|
},
|
|
@@ -18,6 +23,9 @@ const dossier = (text) => jsonValueSchema.parse({
|
|
|
18
23
|
referenced_strings: [],
|
|
19
24
|
referenced_names: [],
|
|
20
25
|
basic_blocks: [{ start: "0x1000", end: "0x1001", successors: [] }],
|
|
26
|
+
native_api: null,
|
|
27
|
+
native_value_flow: null,
|
|
28
|
+
limitations: ["The fixture omits native API and value-flow observations."],
|
|
21
29
|
});
|
|
22
30
|
const observe = (digit, text) => createEvidence({
|
|
23
31
|
path: `/tmp/function-${digit}`,
|