rea-agents 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -19
- package/bridge/ghidra/ReaGhidraBridge.java +524 -4
- package/bridge/hopper_bridge.py +313 -28
- package/dist/application/AnalysisClientCleanup.js +14 -0
- package/dist/application/AnalysisContextQueries.js +130 -0
- package/dist/application/AnalysisSnapshotCache.js +4 -2
- package/dist/application/ApplicationWorkflowEvidenceResolver.js +31 -13
- package/dist/application/ArtifactInventory/scanCanonical.js +1 -1
- package/dist/application/BinarySession.js +20 -8
- package/dist/application/BinarySessionComposition.js +21 -0
- package/dist/application/BinarySessionRecords.js +79 -9
- package/dist/application/BinarySessionStatus.js +31 -1
- package/dist/application/BrowserEvidence.js +14 -0
- package/dist/application/BrowserScenarioCapturePort.js +1 -0
- package/dist/application/BrowserScenarioCaptureService.js +53 -0
- package/dist/application/BrowserScenarioEvidence.js +40 -0
- package/dist/application/CallPathTracing.js +160 -0
- package/dist/application/CapabilityInventory.js +84 -14
- package/dist/application/ClientRegistrationStatus.js +4 -1
- package/dist/application/CompositeProvider.js +10 -1
- package/dist/application/DirectAnalysis.js +13 -4
- package/dist/application/EnhancedLiteralTracing.js +118 -0
- package/dist/application/EnhancedTools.js +71 -127
- package/dist/application/EvidenceLedger.js +45 -16
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +13 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +27 -1
- package/dist/application/JavaScriptArtifactAnalysis.js +13 -4
- package/dist/application/JavaScriptRuntimeObservationEvidence.js +34 -0
- package/dist/application/JavaScriptRuntimeObservationPort.js +1 -0
- package/dist/application/JavaScriptRuntimeObservationService.js +46 -0
- package/dist/application/JavaScriptSemanticGraphAsyncProjection.js +147 -0
- package/dist/application/JavaScriptSemanticGraphBuilder.js +34 -6
- package/dist/application/JavaScriptSemanticGraphChildProcessProjection.js +156 -0
- package/dist/application/JavaScriptSemanticGraphConstruction.js +2 -2
- package/dist/application/JavaScriptSemanticGraphDataProjection.js +203 -0
- package/dist/application/JavaScriptSemanticGraphFingerprintProjection.js +25 -0
- package/dist/application/JavaScriptSemanticGraphFlowProjection.js +129 -8
- package/dist/application/JavaScriptSemanticGraphObjectProjection.js +81 -0
- package/dist/application/JavaScriptSemanticGraphProjection.js +14 -7
- package/dist/application/JavaScriptSemanticGraphResourceProjection.js +59 -0
- package/dist/application/JavaScriptSemanticGraphValueProjection.js +77 -0
- package/dist/application/LazyAnalysisProvider.js +77 -0
- package/dist/application/LoopbackReplay.js +1 -1
- package/dist/application/NativeApiInspection.js +80 -0
- package/dist/application/ProcessReactiveEffects.js +6 -0
- package/dist/application/ProcessReactiveHarness.js +16 -1
- package/dist/application/ProjectPermissionStore.js +1 -0
- package/dist/application/ReconstructionObligationAuthority.js +72 -0
- package/dist/application/ReconstructionObligationCandidates.js +265 -0
- package/dist/application/ReconstructionObligationLedgerDiagnostics.js +47 -0
- package/dist/application/ReconstructionObligationLedgerEvaluation.js +263 -0
- package/dist/application/ReconstructionObligationLedgerProjection.js +86 -0
- package/dist/application/ReconstructionObligationLedgerService.js +72 -0
- package/dist/application/ReconstructionObligationOriginalCases.js +33 -0
- package/dist/application/ReconstructionObligationPolicies.js +132 -0
- package/dist/application/ReconstructionReadinessService.js +48 -0
- package/dist/application/SessionProviderRouter.js +6 -6
- package/dist/application/SetupClientConfiguration.js +4 -2
- package/dist/application/runtime.js +26 -9
- package/dist/artifacts/ArtifactProvider.js +87 -22
- package/dist/browser/BrowserScenarioSecrets.js +53 -0
- package/dist/browser/BrowserScenarioSessionPort.js +1 -0
- package/dist/browser/CdpBrowserProvider.js +2 -2
- package/dist/browser/CdpCaptureDocuments.js +57 -0
- package/dist/browser/CdpCaptureStorage.js +71 -29
- package/dist/browser/CdpCaptureStorageFingerprints.js +328 -0
- package/dist/browser/CdpEndpoint.js +8 -6
- package/dist/browser/CdpPageCapture.js +2 -0
- package/dist/browser/JavaScriptRuntimeScope.js +38 -0
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +259 -0
- package/dist/browser/PlaywrightExecutionBoundary.js +42 -0
- package/dist/browser/PlaywrightScenarioActions.js +62 -0
- package/dist/browser/PlaywrightScenarioArtifacts.js +238 -0
- package/dist/browser/PlaywrightScenarioBrowser.js +144 -0
- package/dist/browser/PlaywrightScenarioEvents.js +301 -0
- package/dist/browser/PlaywrightScenarioSession.js +300 -0
- package/dist/browser/V8InspectorCaptureProjection.js +110 -0
- package/dist/browser/V8InspectorEndpoint.js +72 -0
- package/dist/browser/V8InspectorProvider.js +267 -0
- package/dist/catalogIdentity.js +11 -3
- package/dist/cli/artifactCommands.js +44 -3
- package/dist/cli/coreAnalysisCommands.js +78 -0
- package/dist/cli.js +4 -0
- package/dist/cliApplicationCommands.js +30 -2
- package/dist/cliBrowserAdvancedCommands.js +17 -5
- package/dist/cliBrowserCommands.js +1 -0
- package/dist/cliBrowserScenarioCommands.js +43 -0
- package/dist/cliCommandNames.js +9 -0
- package/dist/cliJavaScriptRuntimeCommands.js +164 -0
- package/dist/cliObservationOptions.js +4 -0
- package/dist/cliPolicyCommands.js +1 -0
- package/dist/config/environment.js +12 -0
- package/dist/config/parseConfig.js +88 -17
- package/dist/contracts/analysisSearchContract.js +14 -0
- package/dist/contracts/applicationToolContracts.js +86 -2
- package/dist/contracts/applicationWorkflowInputContracts.js +18 -0
- package/dist/contracts/artifactToolContracts.js +29 -2
- package/dist/contracts/browserProviderToolContracts.js +7 -0
- package/dist/contracts/browserScenarioToolContracts.js +81 -0
- package/dist/contracts/browserToolContracts.js +88 -98
- package/dist/contracts/enhancedInputs.js +35 -6
- package/dist/contracts/functionInstructionContract.js +8 -0
- package/dist/contracts/functionWorkflowToolContracts.js +30 -0
- package/dist/contracts/hopperMemoryContracts.js +22 -0
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +42 -0
- package/dist/contracts/javascriptRuntimeObservationToolContracts.js +58 -0
- package/dist/contracts/promptContracts.js +14 -15
- package/dist/contracts/reconstructionReadinessExample.js +436 -0
- package/dist/contracts/toolContractExamples.js +8 -0
- package/dist/contracts/toolContractTypes.js +1 -0
- package/dist/contracts/toolContracts.js +34 -25
- package/dist/contracts/toolEffects.js +25 -0
- package/dist/contracts/toolOutputSchemaGroups.js +120 -30
- package/dist/contracts/toolOutputSchemaPrimitives.js +37 -0
- package/dist/domain/analysisErrorPresentation.js +8 -2
- package/dist/domain/analysisErrorProjection.js +9 -0
- package/dist/domain/artifactInspection.js +347 -0
- package/dist/domain/browserCaptureComparison.js +82 -0
- package/dist/domain/browserObservation.js +8 -1
- package/dist/domain/browserObservationErrors.js +1 -0
- package/dist/domain/browserObservationSchemas.js +26 -0
- package/dist/domain/browserScenario.js +165 -0
- package/dist/domain/browserScenarioCapture.js +57 -0
- package/dist/domain/browserScenarioCaptureValues.js +204 -0
- package/dist/domain/browserScenarioDiff.js +324 -0
- package/dist/domain/browserScenarioDiffValues.js +157 -0
- package/dist/domain/browserScenarioNormalization.js +45 -0
- package/dist/domain/browserScenarioValues.js +372 -0
- package/dist/domain/bytecodeProvider.js +179 -0
- package/dist/domain/conformancePackage.js +169 -0
- package/dist/domain/conformanceReplay.js +104 -0
- package/dist/domain/conformanceTrustGate.js +193 -0
- package/dist/domain/customProtocolCapture.js +137 -0
- package/dist/domain/eventProcessTree.js +214 -0
- package/dist/domain/evidenceBundle.js +47 -0
- package/dist/domain/hopperStartupFailure.js +1 -1
- package/dist/domain/hopperValues.js +14 -1
- package/dist/domain/inputIssueProjection.js +7 -1
- package/dist/domain/javascriptRuntimeObservation.js +170 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +120 -2
- package/dist/domain/javascriptRuntimeReconciliationResult.js +3 -3
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +2 -2
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +1 -1
- package/dist/domain/javascriptSemanticAnalysis.js +13 -16
- package/dist/domain/javascriptSemanticAsyncEffects.js +253 -0
- package/dist/domain/javascriptSemanticChildProcesses.js +237 -0
- package/dist/domain/javascriptSemanticDataEffectHelpers.js +125 -0
- package/dist/domain/javascriptSemanticDataEffects.js +284 -0
- package/dist/domain/javascriptSemanticDerivedAnalysis.js +41 -0
- package/dist/domain/javascriptSemanticFingerprints.js +174 -0
- package/dist/domain/javascriptSemanticIr.js +21 -1
- package/dist/domain/javascriptSemanticObjects.js +115 -0
- package/dist/domain/javascriptSemanticPromises.js +290 -0
- package/dist/domain/javascriptSemanticResources.js +136 -0
- package/dist/domain/javascriptSourceParser.js +15 -0
- package/dist/domain/javascriptStaticAnalysis.js +12 -15
- package/dist/domain/javascriptStaticAnalysisBundler.js +38 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +23 -1
- package/dist/domain/javascriptStaticAnalysisHelpers.js +8 -0
- package/dist/domain/mobileApplicationInvestigation.js +159 -0
- package/dist/domain/nativeApiBoundary.js +130 -0
- package/dist/domain/objcSwiftMetadata.js +150 -0
- package/dist/domain/packageAnalysis.js +123 -0
- package/dist/domain/peInspection.js +196 -0
- package/dist/domain/processCapture.js +8 -2
- package/dist/domain/processReactiveScenario.js +1 -0
- package/dist/domain/processReactiveTransition.js +9 -4
- package/dist/domain/protocolCapture.js +243 -0
- package/dist/domain/providerCleanupError.js +11 -0
- package/dist/domain/reconstructionObligationLedgerSchemas.js +278 -0
- package/dist/domain/reconstructionReadiness.js +121 -0
- package/dist/domain/reconstructionReadinessFindingHelpers.js +17 -0
- package/dist/domain/reconstructionReadinessIntegrityFindings.js +118 -0
- package/dist/domain/reconstructionReadinessJourneyFindings.js +193 -0
- package/dist/domain/reconstructionReadinessSchemas.js +240 -0
- package/dist/domain/sourceToBundleComparison.js +335 -0
- package/dist/domain/sourceToBundleComparisonSchemas.js +133 -0
- package/dist/domain/sourceToBundleSignals.js +202 -0
- package/dist/domain/webCaptureDiff.js +141 -27
- package/dist/domain/webScreenshot.js +1 -1
- package/dist/dotnet/ManagedStaticProvider.js +34 -5
- package/dist/generatedMcpToolCatalog.js +37 -0
- package/dist/generatedPackageMetadata.js +4 -4
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraFunctionValues.js +40 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +47 -38
- package/dist/hopper/HopperCleanup.js +158 -0
- package/dist/hopper/HopperClient.js +93 -99
- package/dist/hopper/HopperProvider.js +61 -30
- package/dist/hopper/HopperRequestQueue.js +215 -0
- package/dist/hopper/HopperResponseStream.js +46 -0
- package/dist/hopper/protocol.js +63 -20
- package/dist/main/transport.js +24 -27
- package/dist/main.js +14 -6
- package/dist/mcpDoctor.js +27 -4
- package/dist/mcpStartupPolicy.js +14 -0
- package/dist/process/ProcessCommandIdentity.js +19 -0
- package/dist/process/ProcessOwnership.js +11 -8
- package/dist/server/DynamicToolAvailability.js +70 -0
- package/dist/server/LazyToolCatalog.js +134 -0
- package/dist/server/createServer.js +92 -154
- package/dist/server/hydrateServerTools.js +191 -0
- package/dist/server/lifecycleProgress.js +10 -0
- package/dist/server/permissionFailure.js +12 -0
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +35 -0
- package/dist/server/registerApplicationTools/helpers.js +11 -7
- package/dist/server/registerApplicationTools/obligationLedger.js +27 -0
- package/dist/server/registerApplicationTools/readiness.js +55 -0
- package/dist/server/registerApplicationTools.js +6 -0
- package/dist/server/registerArtifactTools.js +9 -1
- package/dist/server/registerBrowserScenarioTool.js +25 -0
- package/dist/server/registerBrowserTools.js +2 -2
- package/dist/server/registerCloseLifecycleTool.js +57 -0
- package/dist/server/registerEnhancedTools.js +28 -7
- package/dist/server/registerEvidenceResources.js +54 -101
- package/dist/server/registerEvidenceTools.js +9 -2
- package/dist/server/registerInvestigationTools.js +1 -2
- package/dist/server/registerJavaScriptApplicationGraphResource.js +0 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +37 -0
- package/dist/server/registerReconstructionObligationLedgerResource.js +32 -0
- package/dist/server/registerReconstructionReadinessResource.js +32 -0
- package/dist/server/registerSessionRecordTools.js +82 -12
- package/dist/server/registerSessionStatusTool.js +11 -8
- package/dist/server/registerSessionTools.js +32 -58
- package/dist/server/sessionAvailabilityPolicy.js +10 -8
- package/dist/server/toolRegistrationOptions.js +21 -6
- package/dist/server/toolResult.js +12 -0
- package/package.json +28 -11
- package/scripts/package-runner-bootstrap.mjs +72 -0
- package/scripts/rea.mjs +11 -1
- package/skills/reverse-engineer-anything/SKILL.md +10 -3
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Objective-C method type. */
|
|
3
|
+
export const objcMethodTypeSchema = z.enum([
|
|
4
|
+
"instance",
|
|
5
|
+
"class",
|
|
6
|
+
"ivar_getter",
|
|
7
|
+
"ivar_setter",
|
|
8
|
+
]);
|
|
9
|
+
/** Objective-C property attribute. */
|
|
10
|
+
export const objcPropertyAttributeSchema = z.strictObject({
|
|
11
|
+
name: z.string().min(1),
|
|
12
|
+
value: z.string(),
|
|
13
|
+
is_weak: z.boolean().default(false),
|
|
14
|
+
is_atomic: z.boolean().default(false),
|
|
15
|
+
is_copy: z.boolean().default(false),
|
|
16
|
+
is_strong: z.boolean().default(false),
|
|
17
|
+
});
|
|
18
|
+
/** Objective-C method metadata. */
|
|
19
|
+
export const objcMethodSchema = z.strictObject({
|
|
20
|
+
selector: z.string().min(1),
|
|
21
|
+
method_type: objcMethodTypeSchema,
|
|
22
|
+
address: z.number().int().nullable(),
|
|
23
|
+
is_required: z.boolean().default(false),
|
|
24
|
+
is_optional: z.boolean().default(false),
|
|
25
|
+
});
|
|
26
|
+
/** Objective-C property metadata. */
|
|
27
|
+
export const objcPropertySchema = z.strictObject({
|
|
28
|
+
name: z.string().min(1),
|
|
29
|
+
type_encoding: z.string().nullable(),
|
|
30
|
+
attributes: z.array(objcPropertyAttributeSchema).default([]),
|
|
31
|
+
is_readonly: z.boolean().default(false),
|
|
32
|
+
getter: z.string().nullable(),
|
|
33
|
+
setter: z.string().nullable(),
|
|
34
|
+
});
|
|
35
|
+
/** Objective-C protocol metadata. */
|
|
36
|
+
export const objcProtocolSchema = z.strictObject({
|
|
37
|
+
name: z.string().min(1),
|
|
38
|
+
methods: z.array(objcMethodSchema).default([]),
|
|
39
|
+
optional_methods: z.array(objcMethodSchema).default([]),
|
|
40
|
+
properties: z.array(objcPropertySchema).default([]),
|
|
41
|
+
});
|
|
42
|
+
/** Objective-C class metadata. */
|
|
43
|
+
export const objcClassSchema = z.strictObject({
|
|
44
|
+
name: z.string().min(1),
|
|
45
|
+
super_class: z.string().nullable(),
|
|
46
|
+
is_meta_class: z.boolean().default(false),
|
|
47
|
+
is_root_class: z.boolean().default(false),
|
|
48
|
+
methods: z.array(objcMethodSchema).default([]),
|
|
49
|
+
properties: z.array(objcPropertySchema).default([]),
|
|
50
|
+
protocols: z.array(z.string()).default([]),
|
|
51
|
+
ivar_count: z.number().int().nonnegative().default(0),
|
|
52
|
+
instance_size: z.number().int().nonnegative().nullable(),
|
|
53
|
+
});
|
|
54
|
+
/** Swift declaration kind. */
|
|
55
|
+
export const swiftDeclKindSchema = z.enum([
|
|
56
|
+
"class",
|
|
57
|
+
"struct",
|
|
58
|
+
"enum",
|
|
59
|
+
"protocol",
|
|
60
|
+
"extension",
|
|
61
|
+
"actor",
|
|
62
|
+
"global_var",
|
|
63
|
+
"global_func",
|
|
64
|
+
]);
|
|
65
|
+
/** Swift access level. */
|
|
66
|
+
export const swiftAccessLevelSchema = z.enum([
|
|
67
|
+
"private",
|
|
68
|
+
"fileprivate",
|
|
69
|
+
"internal",
|
|
70
|
+
"public",
|
|
71
|
+
"open",
|
|
72
|
+
]);
|
|
73
|
+
/** Swift declaration metadata. */
|
|
74
|
+
export const swiftDeclSchema = z.strictObject({
|
|
75
|
+
kind: swiftDeclKindSchema,
|
|
76
|
+
name: z.string().min(1),
|
|
77
|
+
module: z.string().nullable(),
|
|
78
|
+
access_level: swiftAccessLevelSchema.default("internal"),
|
|
79
|
+
super_class: z.string().nullable(),
|
|
80
|
+
protocols: z.array(z.string()).default([]),
|
|
81
|
+
is_final: z.boolean().default(false),
|
|
82
|
+
is_required: z.boolean().default(false),
|
|
83
|
+
is_convenience_init: z.boolean().default(false),
|
|
84
|
+
is_override: z.boolean().default(false),
|
|
85
|
+
});
|
|
86
|
+
/** Database save/read operation type. */
|
|
87
|
+
export const dbOperationSchema = z.enum([
|
|
88
|
+
"save",
|
|
89
|
+
"readback",
|
|
90
|
+
"open_database",
|
|
91
|
+
"close_database",
|
|
92
|
+
"export",
|
|
93
|
+
"import",
|
|
94
|
+
]);
|
|
95
|
+
/** Database save operation result. */
|
|
96
|
+
export const dbSaveResultSchema = z.strictObject({
|
|
97
|
+
operation: dbOperationSchema,
|
|
98
|
+
succeeded: z.boolean(),
|
|
99
|
+
preserved_names: z.number().int().nonnegative().default(0),
|
|
100
|
+
preserved_comments: z.number().int().nonnegative().default(0),
|
|
101
|
+
preserved_bookmarks: z.number().int().nonnegative().default(0),
|
|
102
|
+
database_path: z.string().nullable(),
|
|
103
|
+
error: z.string().nullable(),
|
|
104
|
+
});
|
|
105
|
+
/** Result of deeper ObjC/Swift metadata extraction. */
|
|
106
|
+
export const objcSwiftMetadataSchema = z.strictObject({
|
|
107
|
+
objc_classes: z.array(objcClassSchema).default([]),
|
|
108
|
+
objc_protocols: z.array(objcProtocolSchema).default([]),
|
|
109
|
+
swift_decls: z.array(swiftDeclSchema).default([]),
|
|
110
|
+
db_save_result: dbSaveResultSchema.nullable(),
|
|
111
|
+
});
|
|
112
|
+
/** Check if a selector name looks like a getter. */
|
|
113
|
+
export function isGetterSelector(selector) {
|
|
114
|
+
return /^[a-z][a-zA-Z0-9_]*$/u.test(selector) && !selector.includes(":");
|
|
115
|
+
}
|
|
116
|
+
/** Check if a selector name looks like a setter. */
|
|
117
|
+
export function isSetterSelector(selector) {
|
|
118
|
+
return selector.startsWith("set") && selector.endsWith(":");
|
|
119
|
+
}
|
|
120
|
+
/** Extract property name from a getter/setter selector. */
|
|
121
|
+
export function propertyNameFromSelector(selector) {
|
|
122
|
+
if (isSetterSelector(selector)) {
|
|
123
|
+
const inner = selector.slice(3, -1);
|
|
124
|
+
return inner.charAt(0).toLowerCase() + inner.slice(1);
|
|
125
|
+
}
|
|
126
|
+
if (isGetterSelector(selector)) {
|
|
127
|
+
return selector;
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
/** Count ObjC methods by type. */
|
|
132
|
+
export function countMethodsByType(methods) {
|
|
133
|
+
return {
|
|
134
|
+
instance: methods.filter((m) => m.method_type === "instance").length,
|
|
135
|
+
class: methods.filter((m) => m.method_type === "class").length,
|
|
136
|
+
ivar_getter: methods.filter((m) => m.method_type === "ivar_getter").length,
|
|
137
|
+
ivar_setter: methods.filter((m) => m.method_type === "ivar_setter").length,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Get all Swift declarations of a specific kind. */
|
|
141
|
+
export function swiftDeclsByKind(decls, kind) {
|
|
142
|
+
return decls.filter((d) => d.kind === kind);
|
|
143
|
+
}
|
|
144
|
+
/** Check if a database save preserved all expected items. */
|
|
145
|
+
export function isDbSaveComplete(result, expectedNames, expectedComments, expectedBookmarks) {
|
|
146
|
+
return (result.succeeded &&
|
|
147
|
+
result.preserved_names >= expectedNames &&
|
|
148
|
+
result.preserved_comments >= expectedComments &&
|
|
149
|
+
result.preserved_bookmarks >= expectedBookmarks);
|
|
150
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Supported Windows package formats. */
|
|
3
|
+
export const packageFormatSchema = z.enum(["msix", "msi", "appx"]);
|
|
4
|
+
/** A resource entry within a package. */
|
|
5
|
+
export const packageResourceSchema = z.strictObject({
|
|
6
|
+
/** Resource path within the package. */
|
|
7
|
+
path: z.string().min(1),
|
|
8
|
+
/** Resource type. */
|
|
9
|
+
type: z.enum([
|
|
10
|
+
"manifest",
|
|
11
|
+
"icon",
|
|
12
|
+
"configuration",
|
|
13
|
+
"certificate",
|
|
14
|
+
"executable",
|
|
15
|
+
"library",
|
|
16
|
+
"data",
|
|
17
|
+
"other",
|
|
18
|
+
]),
|
|
19
|
+
/** Size in bytes. */
|
|
20
|
+
size: z.number().int().nonnegative(),
|
|
21
|
+
/** SHA-256 digest. */
|
|
22
|
+
digest: z
|
|
23
|
+
.string()
|
|
24
|
+
.regex(/^[a-f0-9]{64}$/u)
|
|
25
|
+
.nullable(),
|
|
26
|
+
});
|
|
27
|
+
/** Digital signature information. */
|
|
28
|
+
export const digitalSignatureSchema = z.strictObject({
|
|
29
|
+
/** Whether the package is signed. */
|
|
30
|
+
is_signed: z.boolean(),
|
|
31
|
+
/** Signer subject name. */
|
|
32
|
+
signer_subject: z.string().nullable(),
|
|
33
|
+
/** Certificate thumbprint. */
|
|
34
|
+
certificate_thumbprint: z.string().nullable(),
|
|
35
|
+
/** Whether the signature is valid. */
|
|
36
|
+
is_valid: z.boolean().default(false),
|
|
37
|
+
/** Whether the signature is timestamped. */
|
|
38
|
+
is_timestamped: z.boolean().default(false),
|
|
39
|
+
/** Timestamp signer if present. */
|
|
40
|
+
timestamp_signer: z.string().nullable(),
|
|
41
|
+
});
|
|
42
|
+
/** A Windows package manifest for static analysis. */
|
|
43
|
+
export const packageManifestSchema = z.strictObject({
|
|
44
|
+
/** Package format. */
|
|
45
|
+
format: packageFormatSchema,
|
|
46
|
+
/** Package identity name. */
|
|
47
|
+
name: z.string().min(1),
|
|
48
|
+
/** Package publisher. */
|
|
49
|
+
publisher: z.string().nullable(),
|
|
50
|
+
/** Package version. */
|
|
51
|
+
version: z.string().nullable(),
|
|
52
|
+
/** Architecture. */
|
|
53
|
+
architecture: z.enum(["x86", "x64", "arm", "arm64", "neutral", "unknown"]),
|
|
54
|
+
/** Package resources. */
|
|
55
|
+
resources: z.array(packageResourceSchema).default([]),
|
|
56
|
+
/** Digital signature. */
|
|
57
|
+
signature: digitalSignatureSchema,
|
|
58
|
+
/** Whether the package is a framework. */
|
|
59
|
+
is_framework: z.boolean().default(false),
|
|
60
|
+
/** Package dependencies. */
|
|
61
|
+
dependencies: z.array(z.string()).default([]),
|
|
62
|
+
/** Capabilities declared in the manifest. */
|
|
63
|
+
capabilities: z.array(z.string()).default([]),
|
|
64
|
+
});
|
|
65
|
+
/** Detect package format from file extension. */
|
|
66
|
+
export function detectPackageFormat(path) {
|
|
67
|
+
const lower = path.toLowerCase();
|
|
68
|
+
if (lower.endsWith(".msix"))
|
|
69
|
+
return "msix";
|
|
70
|
+
if (lower.endsWith(".msi"))
|
|
71
|
+
return "msi";
|
|
72
|
+
if (lower.endsWith(".appx"))
|
|
73
|
+
return "appx";
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/** Check if a resource path looks like a manifest. */
|
|
77
|
+
export function isManifestResource(path) {
|
|
78
|
+
const lower = path.toLowerCase();
|
|
79
|
+
return (lower.includes("appxmanifest.xml") ||
|
|
80
|
+
lower.includes("appxmanifest") ||
|
|
81
|
+
lower.includes("manifest.xml") ||
|
|
82
|
+
lower.endsWith("_manifest.xml"));
|
|
83
|
+
}
|
|
84
|
+
/** Check if a resource path looks like a configuration file. */
|
|
85
|
+
export function isConfigurationResource(path) {
|
|
86
|
+
const lower = path.toLowerCase();
|
|
87
|
+
return (lower.endsWith(".xml") ||
|
|
88
|
+
lower.endsWith(".json") ||
|
|
89
|
+
lower.endsWith(".ini") ||
|
|
90
|
+
lower.endsWith(".config"));
|
|
91
|
+
}
|
|
92
|
+
/** Classify a resource by its path. */
|
|
93
|
+
export function classifyResource(path) {
|
|
94
|
+
if (isManifestResource(path))
|
|
95
|
+
return "manifest";
|
|
96
|
+
const lower = path.toLowerCase();
|
|
97
|
+
if (lower.endsWith(".ico") ||
|
|
98
|
+
lower.endsWith(".png") ||
|
|
99
|
+
lower.endsWith(".jpg") ||
|
|
100
|
+
lower.endsWith(".jpeg"))
|
|
101
|
+
return "icon";
|
|
102
|
+
if (isConfigurationResource(path))
|
|
103
|
+
return "configuration";
|
|
104
|
+
if (lower.endsWith(".cer") ||
|
|
105
|
+
lower.endsWith(".pfx") ||
|
|
106
|
+
lower.endsWith(".p12"))
|
|
107
|
+
return "certificate";
|
|
108
|
+
if (lower.endsWith(".exe") || lower.endsWith(".dll"))
|
|
109
|
+
return lower.endsWith(".exe") ? "executable" : "library";
|
|
110
|
+
return "other";
|
|
111
|
+
}
|
|
112
|
+
/** Get all resources of a specific type. */
|
|
113
|
+
export function resourcesByType(manifest, type) {
|
|
114
|
+
return manifest.resources.filter((r) => r.type === type);
|
|
115
|
+
}
|
|
116
|
+
/** Get the total size of all resources. */
|
|
117
|
+
export function totalResourceSize(manifest) {
|
|
118
|
+
return manifest.resources.reduce((sum, r) => sum + r.size, 0);
|
|
119
|
+
}
|
|
120
|
+
/** Check if a package has a valid signature. */
|
|
121
|
+
export function hasValidSignature(manifest) {
|
|
122
|
+
return manifest.signature.is_signed && manifest.signature.is_valid;
|
|
123
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** PE/COFF section characteristics flags. */
|
|
3
|
+
export const sectionCharacteristicsSchema = z.object({
|
|
4
|
+
/** Section contains executable code. */
|
|
5
|
+
has_code: z.boolean().default(false),
|
|
6
|
+
/** Section contains initialized data. */
|
|
7
|
+
has_initialized_data: z.boolean().default(false),
|
|
8
|
+
/** Section contains uninitialized data. */
|
|
9
|
+
has_uninitialized_data: z.boolean().default(false),
|
|
10
|
+
/** Section can be read. */
|
|
11
|
+
readable: z.boolean().default(false),
|
|
12
|
+
/** Section can be written. */
|
|
13
|
+
writable: z.boolean().default(false),
|
|
14
|
+
/** Section can be executed. */
|
|
15
|
+
executable: z.boolean().default(false),
|
|
16
|
+
});
|
|
17
|
+
/** PE/COFF section header. */
|
|
18
|
+
export const peSectionSchema = z.strictObject({
|
|
19
|
+
name: z.string().min(1),
|
|
20
|
+
virtual_size: z.number().int().nonnegative(),
|
|
21
|
+
virtual_address: z.number().int().nonnegative(),
|
|
22
|
+
raw_size: z.number().int().nonnegative(),
|
|
23
|
+
raw_offset: z.number().int().nonnegative(),
|
|
24
|
+
characteristics: sectionCharacteristicsSchema,
|
|
25
|
+
});
|
|
26
|
+
/** PE import entry. */
|
|
27
|
+
export const peImportSchema = z.strictObject({
|
|
28
|
+
dll: z.string().min(1),
|
|
29
|
+
function_name: z.string().min(1),
|
|
30
|
+
ordinal: z.number().int().nullable(),
|
|
31
|
+
is_delay_import: z.boolean().default(false),
|
|
32
|
+
});
|
|
33
|
+
/** PE export entry. */
|
|
34
|
+
export const peExportSchema = z.strictObject({
|
|
35
|
+
name: z.string().min(1),
|
|
36
|
+
ordinal: z.number().int().nonnegative(),
|
|
37
|
+
rva: z.number().int().nonnegative(),
|
|
38
|
+
forwarder: z.string().nullable(),
|
|
39
|
+
});
|
|
40
|
+
/** PE/COFF resource entry. */
|
|
41
|
+
export const peResourceSchema = z.strictObject({
|
|
42
|
+
type: z.string().min(1),
|
|
43
|
+
name: z.string().nullable(),
|
|
44
|
+
language: z.number().int().nullable(),
|
|
45
|
+
rva: z.number().int().nonnegative(),
|
|
46
|
+
size: z.number().int().nonnegative(),
|
|
47
|
+
});
|
|
48
|
+
/** PE debug directory entry. */
|
|
49
|
+
export const peDebugEntrySchema = z.strictObject({
|
|
50
|
+
type: z.string().min(1),
|
|
51
|
+
rva: z.number().int().nonnegative(),
|
|
52
|
+
size: z.number().int().nonnegative(),
|
|
53
|
+
/** PDB GUID if this is a CodeView entry. */
|
|
54
|
+
pdb_guid: z.string().nullable(),
|
|
55
|
+
/** PDB age if this is a CodeView entry. */
|
|
56
|
+
pdb_age: z.number().int().nullable(),
|
|
57
|
+
/** PDB path if this is a CodeView entry. */
|
|
58
|
+
pdb_path: z.string().nullable(),
|
|
59
|
+
});
|
|
60
|
+
/** TLS callback entry. */
|
|
61
|
+
export const peTlsCallbackSchema = z.strictObject({
|
|
62
|
+
callback_rva: z.number().int().nonnegative(),
|
|
63
|
+
index: z.number().int().nonnegative(),
|
|
64
|
+
});
|
|
65
|
+
/** Architecture/machine type. */
|
|
66
|
+
export const peMachineTypeSchema = z.enum([
|
|
67
|
+
"x86",
|
|
68
|
+
"x64",
|
|
69
|
+
"arm",
|
|
70
|
+
"arm64",
|
|
71
|
+
"ia64",
|
|
72
|
+
"unknown",
|
|
73
|
+
]);
|
|
74
|
+
/** PE/COFF manifest for static inspection. */
|
|
75
|
+
export const peManifestSchema = z.strictObject({
|
|
76
|
+
/** DOS header magic. */
|
|
77
|
+
dos_magic: z.literal(0x5a4d),
|
|
78
|
+
/** PE signature. */
|
|
79
|
+
pe_signature: z.literal(0x00004550),
|
|
80
|
+
/** Machine type. */
|
|
81
|
+
machine: peMachineTypeSchema,
|
|
82
|
+
/** Number of sections. */
|
|
83
|
+
number_of_sections: z.number().int().positive(),
|
|
84
|
+
/** Timestamp from the COFF header. */
|
|
85
|
+
timestamp: z.number().int().nullable(),
|
|
86
|
+
/** PE characteristics flags. */
|
|
87
|
+
is_dll: z.boolean().default(false),
|
|
88
|
+
is_executable: z.boolean().default(false),
|
|
89
|
+
is_console: z.boolean().default(true),
|
|
90
|
+
/** Entry point RVA. */
|
|
91
|
+
entry_point: z.number().int().nonnegative(),
|
|
92
|
+
/** Image base. */
|
|
93
|
+
image_base: z.number().int().nonnegative(),
|
|
94
|
+
/** Section alignment. */
|
|
95
|
+
section_alignment: z.number().int().positive(),
|
|
96
|
+
/** Subsystem version. */
|
|
97
|
+
subsystem_version: z.string().nullable(),
|
|
98
|
+
/** Sections. */
|
|
99
|
+
sections: z.array(peSectionSchema).min(0).max(96),
|
|
100
|
+
/** Imports. */
|
|
101
|
+
imports: z.array(peImportSchema).default([]),
|
|
102
|
+
/** Exports. */
|
|
103
|
+
exports: z.array(peExportSchema).default([]),
|
|
104
|
+
/** Resources. */
|
|
105
|
+
resources: z.array(peResourceSchema).default([]),
|
|
106
|
+
/** Debug directory entries. */
|
|
107
|
+
debug_entries: z.array(peDebugEntrySchema).default([]),
|
|
108
|
+
/** TLS callbacks. */
|
|
109
|
+
tls_callbacks: z.array(peTlsCallbackSchema).default([]),
|
|
110
|
+
/** Relocations count (not all entries). */
|
|
111
|
+
relocations_count: z.number().int().nonnegative().default(0),
|
|
112
|
+
/** Image file characteristics. */
|
|
113
|
+
image_characteristics: z.array(z.string()).default([]),
|
|
114
|
+
});
|
|
115
|
+
/** Parse machine type from COFF machine field. */
|
|
116
|
+
export function parseMachineType(machine) {
|
|
117
|
+
switch (machine) {
|
|
118
|
+
case 0x014c:
|
|
119
|
+
return "x86";
|
|
120
|
+
case 0x8664:
|
|
121
|
+
return "x64";
|
|
122
|
+
case 0x01c0:
|
|
123
|
+
case 0x01c4:
|
|
124
|
+
return "arm";
|
|
125
|
+
case 0xaa64:
|
|
126
|
+
return "arm64";
|
|
127
|
+
case 0x0200:
|
|
128
|
+
return "ia64";
|
|
129
|
+
default:
|
|
130
|
+
return "unknown";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Parse section characteristics flags. */
|
|
134
|
+
export function parseSectionCharacteristics(characteristics) {
|
|
135
|
+
const IMAGE_SCN_CNT_CODE = 0x00000020;
|
|
136
|
+
const IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040;
|
|
137
|
+
const IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080;
|
|
138
|
+
const IMAGE_SCN_MEM_READ = 0x40000000;
|
|
139
|
+
const IMAGE_SCN_MEM_WRITE = 0x80000000;
|
|
140
|
+
const IMAGE_SCN_MEM_EXECUTE = 0x20000000;
|
|
141
|
+
return {
|
|
142
|
+
has_code: (characteristics & IMAGE_SCN_CNT_CODE) !== 0,
|
|
143
|
+
has_initialized_data: (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) !== 0,
|
|
144
|
+
has_uninitialized_data: (characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) !== 0,
|
|
145
|
+
readable: (characteristics & IMAGE_SCN_MEM_READ) !== 0,
|
|
146
|
+
writable: (characteristics & IMAGE_SCN_MEM_WRITE) !== 0,
|
|
147
|
+
executable: (characteristics & IMAGE_SCN_MEM_EXECUTE) !== 0,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Parse image characteristics flags. */
|
|
151
|
+
export function parseImageCharacteristics(characteristics) {
|
|
152
|
+
const IMAGE_DLL = 0x2000;
|
|
153
|
+
const IMAGE_EXECUTABLE = 0x0002;
|
|
154
|
+
const IMAGE_CONSOLE = 0x0003;
|
|
155
|
+
const flags = [];
|
|
156
|
+
if (characteristics & IMAGE_DLL)
|
|
157
|
+
flags.push("DLL");
|
|
158
|
+
if (characteristics & IMAGE_EXECUTABLE)
|
|
159
|
+
flags.push("Executable");
|
|
160
|
+
if ((characteristics & 0x0000000f) === IMAGE_CONSOLE)
|
|
161
|
+
flags.push("Console");
|
|
162
|
+
return flags;
|
|
163
|
+
}
|
|
164
|
+
/** Parse a PE debug directory type. */
|
|
165
|
+
export function parseDebugType(type) {
|
|
166
|
+
switch (type) {
|
|
167
|
+
case 0:
|
|
168
|
+
return "UNKNOWN";
|
|
169
|
+
case 1:
|
|
170
|
+
return "COFF";
|
|
171
|
+
case 2:
|
|
172
|
+
return "CODEVIEW";
|
|
173
|
+
case 3:
|
|
174
|
+
return "POGO";
|
|
175
|
+
case 4:
|
|
176
|
+
return "MISC";
|
|
177
|
+
default:
|
|
178
|
+
return "UNKNOWN";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/** Check if a PE manifest has PDB debug info. */
|
|
182
|
+
export function hasPdbInfo(manifest) {
|
|
183
|
+
return manifest.debug_entries.some((e) => e.pdb_guid !== null && e.pdb_path !== null);
|
|
184
|
+
}
|
|
185
|
+
/** Get all imported DLLs from a PE manifest. */
|
|
186
|
+
export function getImportedDlls(manifest) {
|
|
187
|
+
return [...new Set(manifest.imports.map((i) => i.dll))];
|
|
188
|
+
}
|
|
189
|
+
/** Get all exported function names from a PE manifest. */
|
|
190
|
+
export function getExportedFunctions(manifest) {
|
|
191
|
+
return manifest.exports.map((e) => e.name);
|
|
192
|
+
}
|
|
193
|
+
/** Count executable sections. */
|
|
194
|
+
export function countExecutableSections(manifest) {
|
|
195
|
+
return manifest.sections.filter((s) => s.characteristics.executable).length;
|
|
196
|
+
}
|
|
@@ -77,7 +77,7 @@ export const processCaptureSchema = z.object({
|
|
|
77
77
|
sequence: z.number().int().nonnegative(),
|
|
78
78
|
scheduled_at_ms: z.number().int().nonnegative(),
|
|
79
79
|
dispatched_at_ms: z.number().int().nonnegative(),
|
|
80
|
-
type: z.enum(["input", "resize", "signal"]),
|
|
80
|
+
type: z.enum(["input", "resize", "stdin_close", "signal"]),
|
|
81
81
|
data: z.string(),
|
|
82
82
|
outcome: z.enum(["dispatched", "target_exited", "failed"]),
|
|
83
83
|
})),
|
|
@@ -202,7 +202,13 @@ export const processCaptureSchema = z.object({
|
|
|
202
202
|
.array(z.string().min(1))
|
|
203
203
|
.max(PROCESS_REACTIVE_LIMITS.actionsPerTransition),
|
|
204
204
|
action_types: z
|
|
205
|
-
.array(z.enum([
|
|
205
|
+
.array(z.enum([
|
|
206
|
+
"send_input",
|
|
207
|
+
"resize",
|
|
208
|
+
"close_stdin",
|
|
209
|
+
"send_signal",
|
|
210
|
+
"checkpoint",
|
|
211
|
+
]))
|
|
206
212
|
.max(PROCESS_REACTIVE_LIMITS.actionsPerTransition),
|
|
207
213
|
}))
|
|
208
214
|
.max(PROCESS_REACTIVE_LIMITS.transitions),
|
|
@@ -128,6 +128,7 @@ const processReactiveActionSchema = z.discriminatedUnion("type", [
|
|
|
128
128
|
columns: z.number().int().min(1).max(1_000),
|
|
129
129
|
rows: z.number().int().min(1).max(1_000),
|
|
130
130
|
}),
|
|
131
|
+
z.strictObject({ type: z.literal("close_stdin") }),
|
|
131
132
|
z.strictObject({
|
|
132
133
|
type: z.literal("send_signal"),
|
|
133
134
|
target: signalTargetSchema,
|
|
@@ -75,6 +75,14 @@ const applyProcessReactiveTransition = (input) => {
|
|
|
75
75
|
record,
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
+
const terminalControlObservationMatches = (action, payload) => {
|
|
79
|
+
if (action.type === "resize")
|
|
80
|
+
return (payload["type"] === "resize" &&
|
|
81
|
+
payload["data"] === `${String(action.columns)}x${String(action.rows)}`);
|
|
82
|
+
if (action.type === "close_stdin")
|
|
83
|
+
return payload["type"] === "stdin_close" && payload["data"] === "";
|
|
84
|
+
return payload["type"] === "signal" && payload["data"] === action.signal;
|
|
85
|
+
};
|
|
78
86
|
const effectObservationMatchesAction = (action, observation, committedSensitiveInputs) => {
|
|
79
87
|
const payload = typeof observation.payload === "object" &&
|
|
80
88
|
observation.payload !== null &&
|
|
@@ -99,10 +107,7 @@ const effectObservationMatchesAction = (action, observation, committedSensitiveI
|
|
|
99
107
|
return (payload["type"] === "input" &&
|
|
100
108
|
payload["data"] ===
|
|
101
109
|
expectedInputEvidence(action.data, action.sensitive, committedSensitiveInputs));
|
|
102
|
-
|
|
103
|
-
return (payload["type"] === "resize" &&
|
|
104
|
-
payload["data"] === `${String(action.columns)}x${String(action.rows)}`);
|
|
105
|
-
return payload["type"] === "signal" && payload["data"] === action.signal;
|
|
110
|
+
return terminalControlObservationMatches(action, payload);
|
|
106
111
|
};
|
|
107
112
|
const expectedInputEvidence = (data, sensitive, committedSensitiveInput) => !sensitive ||
|
|
108
113
|
(committedSensitiveInput && /^<redacted-input:\d+-bytes>$/.test(data))
|